Prometheus统计查询

问题描述 投票:0回答:1

我正在尝试使用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个回答
0
投票

您要执行的操作称为aggregation over time。在您的情况下,它是30分钟内指标的总和:

sum_over_time(probe_success[30m])

请注意,您要计算的内容很难采取行动,因为这取决于最近30分钟的刮擦次数。原因是,如果导出器或Prometheus处于关闭状态(意味着未生成任何度量标准),或者如果您更改了Prometheus中的刮擦间隔,则值的含义将改变。

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

© www.soinside.com 2019 - 2024. All rights reserved.