繁体   English   中英

PromQL 查询中的动态阈值

[英]Dynamic Thresholds in a PromQL query

我有以下定义

    - record: node_load5:node_cpu_seconds_total:critical
      expr: 3

    - record: node_load5:node_cpu_seconds_total:critical
      expr: 5
      labels:
        app: loki

    - record: Node_High_LoadAverage:Query
      expr: ((node_load5 / count without (cpu, mode) (node_cpu_seconds_total{mode="system"})))

并希望在 Prometheus 警报中使用查询,该查询通过 label 指定的值或默认值评估阈值。

我可以将node_load5:node_cpu_seconds_total:critical评估为两个不同的值,并使用Node_High_LoadAverage:Query来缩写查询。

我正在尝试使用group_lefton执行加入。 这是我的查询不起作用。

Node_High_LoadAverage:Query > on (app) group_left node_load5:node_cpu_seconds_total:critical

有没有人做过类似的事情并愿意分享他们的工作示例?

谢谢!

我想到了。

something > on (team) group_left something_too_high_threshold

这使用基于“团队”label 的“加入”运算符来应用不同的度量和阈值。 在此示例中,“团队”label 必须存在于“某物”指标以及不同的“某物_too_high_threshold”表达式中。

这是模拟这个的规则。

    - record: something
      expr: 600
    - record: something
      expr: 400
      labels:
        team: elsewhere
    - record: something
      expr: 300
      labels:
        team: foo
    - record: something
      expr: 500
      labels:
        team: bar
    - record: something_too_high_threshold
      expr: 200
      labels:
        team: foo
    - record: something_too_high_threshold
      expr: 400
      labels:
        team: bar

这可以通过处理不存在 label 的指标来改进。

something > on (team) group_left() ( something_too_high_threshold or on (team) something * 0 + 100 )

这使用上述相同的模型规则并提供默认值“某物”指标,这些指标要么不包括 label,要么未在 something_too_high_threshold 中定义

这个 web 页面, https://www.robustperception.io/using-time-series-as-alert-thresholds帮助我解决了这个问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM