【问题标题】:Finding out distinct value for a label in Prometheus and setup an alert在 Prometheus 中找出标签的不同值并设置警报
【发布时间】:2020-07-12 12:10:38
【问题描述】:

我有一个案例,我想设置一个警报,其中标签的至少一个值是不同的。

例如,度量为test_metric{cluster_name="xyz",os="ubuntu"} 的 Kubernetes 集群 xyz(有 20 个节点)。如果这 20 个节点中的任何一个具有不同的“os”值,我想找出/设置警报。

基本上,这个想法是在集群中所有节点的操作系统值不同时获得警报。

目前我正在测试一个我认为不正确的非常简单的规则:

count(test_metric{cluster_name="xyz",os!=""} != count(test_metric{cluster_name="xyz",os!=""})

【问题讨论】:

    标签: kubernetes monitoring prometheus prometheus-alertmanager


    【解决方案1】:

    嵌套计数是处理这个问题的方法:

    count by (cluster_name) (
       count by (os, cluster_name)(test_metric)
    ) != 1
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-13
      • 1970-01-01
      • 2021-04-24
      • 1970-01-01
      • 1970-01-01
      • 2021-11-22
      • 2020-03-03
      • 1970-01-01
      相关资源
      最近更新 更多