Ser*_*vko 5 prometheus prometheus-alertmanager
我在 prometheus alertmanager 中创建了一个规则,它以百分比表示挂载点上的最小空间 - 除此之外,我想以千兆字节显示最小空间,但我不想硬编码挂载点以显示千兆字节,我想使用 $ label.mountpoint 来自 "expr" ,而不是硬编码。
我在这个链接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 }}"
Run Code Online (Sandbox Code Playgroud)
当我node_filesystem_avail_bytes / 1024 / 1024 / 1024在 in 中使用时VALUE,我不从表达式中获取挂载点,但我知道实际值在哪里 - 它在 $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 }}"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2996 次 |
| 最近记录: |