0

利用 prometheus federation 进行 kubernetes 监控。

尝试为多个集群更改此 promql 查询:

数数

by(node) (sum by(node, cpu) (node_cpu_seconds_total{job="node-exporter"}
  * on(namespace, pod) group_left(node) node_namespace_pod:kube_pod_info:))
For multiple clusters, the query is giving:
Error executing query: found duplicate series for the match group {namespace="monitoring", pod="prometheus-k8s-1"} on the right hand-side of the operation: [{__name__="node_namespace_pod:kube_pod_info:", clustername="xyz", environment="dev", job="prometheus", location="haha", namespace="monitoring", node="228d5f45-27cc-4a59-b99d-3bab9ebe3b52", pod="prometheus-k8s-1", prometheus="monitoring/k8s", prometheus_replica="prometheus-k8s-0"}, {__name__="node_namespace_pod:kube_pod_info:", clustername="abc", environment="dev", job="prometheus", location="haha", namespace="monitoring", node="3faf3dfa-f8ab-4b3f-bda7-6662c1aa2a34", pod="prometheus-k8s-1", prometheus="monitoring/k8s", prometheus_replica="prometheus-k8s-1"}];many-to-many matching not allowed: matching labels must be unique on one side

将 clustername 作为外部标签添加到 prometheus 服务器。

请你指导我好吗?

4

1 回答 1

0

由于 prometheus pod 作为 statefulset 运行,因此出现了重复错误。Pod 名称是prometheus-k8s-1并且它不会更改。

您可能需要在on(namespace, pod)uid 之类的其他参数中使用某些其他参数,或者在任何情况下都是唯一的其他参数。

于 2020-03-11T02:49:58.280 回答