[英]How to display values of metrics in alert rules prometheus
我在prometheus alertmanager中创建了一个规则,该规则以百分比表示安装点上的最小空间-除此之外,我想显示多少最小空间(以GB为单位),但是我不想对安装点进行硬编码以显示千兆字节,我想使用$来自“ expr”而不是硬编码的labels.mountpoint。
我在此链接https://github.com/prometheus/alertmanager/issues/549上找到了类似的问题,但在这种情况下使用了硬编码的挂载点
这是我的规则
- 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 }}"
当我在VALUE
使用node_filesystem_avail_bytes / 1024 / 1024 / 1024
时,我没有从表达式中获取挂载点,但是我知道实际值在哪里,它在$ labels.mountpoint中,我无法在模板中使用或不知道如何使用去做这个
- 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 }}"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.