
目前在 alert 中 expr 那一行,是不生效的。 有没有办法让 alert 中调用 record 中的值。
groups: - name: node.rule rules: - record: node_disk_usage_waring expr: 70 - alert: 主机磁盘使用率过高 expr: node_disk_usage > node_disk_usage_waring for: 10s annotations: description: warning severity: warning 想这么做的原因是,在 prometheus 的生态中,触发报警(prometheus)和图表展示(grafana)是分离的,我想通过一个地方设置报警值,在其他地方都能读到,在图表中直接展现出来。
各位大佬们有没有办法实现
1 dier Apr 13, 2022 |
2 Aliencn OP @dier 现在的情况就是在 alert 的 expr 中, prometheus 中的变量与常量做比较,可以触发报警。 record 的值和常量做比较也,可以触发报警(就是你的第二张图里的) prometheus 中的变量与 prometheus 中的变量做比较,可以触发报警。 record 的值与 record 的值做比较,可以触发报警 但是 prometheus 中的变量与 record 的值做比较,就不能出发报警(就是我主题里写的那个配置) |
3 Aliencn OP 找到原因了,是因为 label 不匹配导致的。 用了个骚方法,保留了 label 值 ``` groups: - name: node.rule rules: - record: node_disk_usage_waring expr: node_disk_usage - node_disk_usage + 10 - alert: 主机磁盘使用率过高 expr: node_disk_usage > node_disk_usage_waring for: 10s annotations: description: warning severity: warning ``` |