Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Prometheus 使用度量名称而不是度量标签进行匹配_Prometheus_Prometheus Alertmanager - Fatal编程技术网

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'