Promql查询联合服务器

时间:2019-09-23 12:20:03

标签: prometheus prometheus-operator

利用普罗米修斯联盟进行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

将集群名称作为外部标签添加到Prometheus服务器。

您能指导我吗?

1 个答案:

答案 0 :(得分:0)

由于prometheus pod作为有状态集运行,因此出现了重复的错误。窗格名称为prometheus-k8s-1,并且不变。

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