【问题标题】:Prometheus statistic query普罗米修斯统计查询
【发布时间】:2020-05-28 21:17:06
【问题描述】:

我正在尝试使用 prometheus-grafana-alertmanager-blackbox_exporter 进行黑盒监控。 我的问题是: 我在一个集群中有很多实例。所以我把它标记为

probe_success{cluster="cluster-1", instance="instance-1"}

probe_success{cluster="cluster-1", instance="instance-2"}

现在我只想计算最近 30m 的范围内,cluster-1 上的 probe_success 指标返回值 1 或 0 的次数。 普罗米修斯真的不能做这件事吗?我找不到任何有关它的文档或问题

【问题讨论】:

    标签: prometheus prometheus-alertmanager prometheus-blackbox-exporter


    【解决方案1】:

    你想做的事叫做aggregation over time。在您的情况下,它将是过去 30 分钟内指标的总和:

    sum_over_time(probe_success[30m])
    

    请注意,您正在计算的内容很难执行,因为它取决于过去 30 分钟内的抓取次数。原因是如果 exporter 或 Prometheus 宕机(意味着没有产生任何指标),或者如果您更改 Prometheus 中的抓取间隔,则该值的含义会​​发生变化。

    通常最好使用avg_over_time 来表示应用程序在过去 30 分钟内可测量的时间百分比。

    【讨论】:

      猜你喜欢
      • 2021-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-22
      • 1970-01-01
      • 1970-01-01
      • 2020-07-16
      • 2017-09-03
      相关资源
      最近更新 更多