我从 prometheus 向 Rocketchat webhook 发送警报。 这是我的警报规则之一的配置:
- alert: HighCpuLoad
expr: 100 - (avg by (instance, group, host) (irate(node_cpu_seconds_total{mode="idle"}[5m])) * 100) > 81
for: 5m
labels:
severity: warning
annotations:
timestamp: "{{ with query "time()" }}{{ . | first | value | humanizeTimestamp }}{{ end }}"
description: "Check CPU load on host {{ $labels.host }}"
firing_text: "CPU load on host {{ $labels.host }} is > 80%\n VALUE = {{ humanize $value }}"
resolved_text: "High CPU load on host {{ $labels.host }} is resolved"
我在注解中定义的所有参数(时间戳、描述、fire_text 和resolution_text)都被发送到alertmanager。但是我没有在 Rocketchat 警报中收到“时间戳”。
这是警报管理器 UI 中的警报: enter image description here
这是出现在 Rocketchat webhook 中的警报消息: enter image description here
如您所见,警报消息中未显示时间戳。
如何让它出现在 webhook 警报消息中?
顺便说一下,我想发送满足条件的点的日期和时间。例如,在我的表达式中,如果我的 CPU 负载在 2020-12-24 08:00:00 达到 80% 以上,它会等待 5 分钟然后发送警报,如果警报管理器队列有其他警报要发送,则需要其他一些分钟将警报发送到 Rocketchat webhook(超过 5 分钟)。 我需要准确发送问题出现的时间点(在本例中为 2020-12-24 08:00:00 而不是 2020-12-24 08:05:00 或 08:06:00)。