Prometheus 使用度量名称而不是度量标签进行匹配
我的一个出口商打印了一个没有标签的度量:Prometheus 使用度量名称而不是度量标签进行匹配,prometheus,prometheus-alertmanager,Prometheus,Prometheus Alertmanager,我的一个出口商打印了一个没有标签的度量: $ curl -s http://localhost:9999/metrics | grep service_up | grep -v "#" service_up 1 创建AlertManager接收器时,我通常会使用一个度量标签来匹配项(例如,作业:“nodeexporter textcollector”) 例如,在这种情况下,AlertManager配置如下所示: route: receiver: 'default'
$ curl -s http://localhost:9999/metrics | grep service_up | grep -v "#"
service_up 1
创建AlertManager接收器时,我通常会使用一个度量标签来匹配项(例如,作业:“nodeexporter textcollector”
)
例如,在这种情况下,AlertManager配置如下所示:
route:
receiver: 'default'
routes:
- receiver: 'custom'
match:
severity: 'critical'
job: 'nodeexporter-textcollector'
但是,对于上述度量(service\u up
)是否可以与度量名称匹配
谢谢。您需要创建一个自定义命名警报,并在其上添加正确的标记。例如,严重性
与本例类似
# alerts/example-redis.yml
groups:
- name: ExampleRedisGroup
rules:
- alert: ExampleRedisDown
expr: redis_up{} == 0
for: 2m
labels:
severity: critical
annotations:
summary: "Redis instance down"
description: "Whatever"
另外,请注意expr
字段,这是alermanager了解需要触发警报的方式。只需检查alertmanager分发版中的alerts
文件夹,就可以看到很多示例
有关创建警报的正式文档:
更多自定义警报示例:您需要创建一个自定义命名警报,并在其上放置正确的标记。例如,严重性
与本例类似
# alerts/example-redis.yml
groups:
- name: ExampleRedisGroup
rules:
- alert: ExampleRedisDown
expr: redis_up{} == 0
for: 2m
labels:
severity: critical
annotations:
summary: "Redis instance down"
description: "Whatever"
另外,请注意expr
字段,这是alermanager了解需要触发警报的方式。只需检查alertmanager分发版中的alerts
文件夹,就可以看到很多示例
有关创建警报的正式文档:
更多自定义警报示例:您已为此指标定义了警报规则,对吗?类似于以下示例:
- alert: ServiceIsDown
expr: service_up == 0
现在,要发送此警报,只需使用警报名称:
route:
receiver: 'default'
routes:
- receiver: 'custom'
match:
alertname: 'ServiceIsDown'
您已为此指标定义了警报规则,对吗?类似于以下示例:
- alert: ServiceIsDown
expr: service_up == 0
现在,要发送此警报,只需使用警报名称:
route:
receiver: 'default'
routes:
- receiver: 'custom'
match:
alertname: 'ServiceIsDown'