如何在警报规则prometheus中显示度量值
我在prometheus alertmanager中创建了一个规则,该规则以百分比表示装入点上的最小空间,除此之外,我还想显示以GB为单位的最小空间量,但我不想硬编码装入点以显示GB,我想使用来自“expr”的$labels.mountpoint,而不是硬编码 我在这个链接上发现了类似的问题 但在这种情况下,使用硬编码挂载点 这是我的规矩如何在警报规则prometheus中显示度量值,prometheus,prometheus-alertmanager,Prometheus,Prometheus Alertmanager,我在prometheus alertmanager中创建了一个规则,该规则以百分比表示装入点上的最小空间,除此之外,我还想显示以GB为单位的最小空间量,但我不想硬编码装入点以显示GB,我想使用来自“expr”的$labels.mountpoint,而不是硬编码 我在这个链接上发现了类似的问题 但在这种情况下,使用硬编码挂载点 这是我的规矩 - alert: OutOfDiskSpace expr: node_filesystem_free_bytes / node_filesystem_
- alert: OutOfDiskSpace
expr: node_filesystem_free_bytes / node_filesystem_size_bytes * 100 < 10
for: 1m
labels:
severity: Critical
annotations:
description: "Disk is almost full (< 10% left)\n {{ $labels.instance_short }}\n {{ $labels.mountpoint }}\n VALUE = {{ printf `node_filesystem_avail_bytes / 1024 / 1024 / 1024` | query | first | value | humanize }}"
-警报:OutOfDiskSpace
expr:node_filesystem_free_bytes/node_filesystem_size_bytes*100<10
时间:100万
标签:
严重程度:严重
注释:
描述:“磁盘几乎满了(<10%左)\n{$labels.instance_short}\n{$labels.mountpoint}\n VALUE={{printf`node`u filesystem_avail_bytes/1024/1024` | query | first | VALUE | humanize}”
当我在VALUE
中使用node\u filesystem\u avail\u bytes/1024/1024/code>时,我没有从表达式中获取装入点,但我知道实际值在哪里,-它在$labels.mountpoint中,我无法在模板中使用,或者不知道如何执行此操作-警报:OutOfDiskSpace
- alert: OutOfDiskSpace
expr: node_filesystem_free_bytes / node_filesystem_size_bytes * 100 < 10
for: 5s
labels:
severity: Critical
annotations:
description: "Disk is almost full (< 10% left)\n {{ $labels.instance_short }}\n {{ $labels.mountpoint }}\n VALUE = {{ printf \"node_filesystem_avail_bytes{mountpoint='%s'}\" .Labels.mountpoint | query | first | value | humanize1024 }}"
expr:node_filesystem_free_bytes/node_filesystem_size_bytes*100<10
适用时间:5s
标签:
严重程度:严重
注释:
描述:“磁盘几乎满了(<10%左)\n{$labels.instance_short}}\n{$labels.mountpoint}\n VALUE={{{printf\'node_filesystem_avail_bytes{mountpoint='%s'}\。labels.mountpoint | query | first | VALUE |人化1024}”
如果要排除某些装入点,需要在“expr”expr:*{mountpoint!~“/mnt/videorec/+\124;/pool/kvm\u fast”}部分编写此代码**