团队,我是普罗米修斯的新人。请协助。
我有一个k8s节点,并且在本地该节点上我有一个正在运行的服务(lustre导出器),它正在公开指标,如下所示。
node:~$ curl http://localhost:9169/metrics | head -n 10
go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 8.4924e-05
go_gc_duration_seconds{quantile="0.25"} 9.0081e-05
go_gc_duration_seconds{quantile="0.5"} 9.2247e-05
我想知道我将如何编写一个服务监视器,以便上面被prometheus刮掉。
我在下面尝试过,但从k8s得到语法错误。
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: lustre-exporter
namespace: team-monitoring
spec:
endpoints:
- path: /metrics
port: "9169"
The ServiceMonitor "lustre-exporter" is invalid: []: Invalid value: map[string]interface {}{"metadata":map[string]interface {}{"name":"lustre-exporter", "namespace":"team-monitoring", "creationTimestamp":"2022-07-01T02:14:16Z", "generation":1, "uid":"824d31a3-f8e3-11ec-b65c-ac1f6b4ea082"}, "spec":map[string]interface {}{"endpoints":[]interface {}{map[string]interface {}{"path":"/metrics", "port":"9169"}}}, "apiVersion":"monitoring.coreos.com/v1", "kind":"ServiceMonitor"}: validation failure list:
spec.selector in body is required
弄清楚并感谢评论中的提示,但标签选择器也不见了。
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: lustre-exporter
namespace: team-monitoring
spec:
endpoints:
- path: /metrics
port: "9169"
selector:
nodeGroup: gpu