Prometheus告警规则模板 rule规则 过程理解
1普通告警模板https://awesome-prometheus-alerts.grep.to/rules#host-and-hardware2 k8s告警模板?operator自带?
推荐阅读:https://www.jianshu.com/p/1697e09e99ac
官方规则模板:https://awesome-prometheus-alerts.grep.to/
groups:
- name: operations
rules:
- alert: node-down
expr: up{env="operations"} != 1
for: 5m
labels:
status: High
team: operations
annotations:
description: "Environment: {{ $labels.env }} Instance: {{ $labels.instance }} is Down ! ! !"
value: '{{ $value }}'
summary: "The host node was down 20 minutes ago"
# 检查语法是否正确
/usr/local/bin/promtool check rules /data/prometheus/rules/ops.yml
#Checking /data/prometheus/rules/ops.yml
# SUCCESS: 7 rules found
状态 描述
1.定义规则 | 在Prometheus配置中,scrape_interval: 15s,默认是1分钟,这个定义是收集监控指标信息的采集周期,同时配置对应的警报规则,可以是全局,也可以单独为某一个metrics定义 |
---|---|
1.定义规则
在Prometheus配置中,scrape_interval: 15s,默认是1分钟,这个定义是收集监控指标信息的采集周期,同时配置对应的警报规则,可以是全局,也可以单独为某一个metrics定义
2.周期计算
对于表达式进行计算时,Prometheus中的配置中配置了 evaluation_interval: 15s,默认也是一分钟,为警报规则的计算周期,evaluation_interval 只是全局计算周期值。
3.1警报状态转换(pending)
当首次触发警报规则条件成立,表达式为 true,并且没有满足警报规则中的for子句中的持续时间时,警报状态切换为 Pending
3.2警报状态转换(firing)
若下一个计算周期中,表达式仍为 true,并且满足警报规则中的for子句的持续时间时,警报状态转换为 Firing,即为 active,警报会被Prometheus推送到ALertmanager组件
3.3警报状态转换(period)
如果在 evaluation_interval 的计算周期内,表达式还是为 true,同时满足 for子句的持续时间,持续转发到Alertmanager,这里只是转发状态到Alertmanager,并不是直接发送通知到指定通知源
3.4警报状态转换(resolve)
只到某个周期,表达式 为 false,警报状态会变成 inactive ,并且会有一个 resolve被发送到Alertmanager,用于说明警报故障依解决,发送resolve信息需要自己单独在Alertmanager中定义
作者:青牛踏雪御苍穹
链接:https://www.jianshu.com/p/1697e09e99ac
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
1 普通告警模板
https://awesome-prometheus-alerts.grep.to/rules#host-and-hardware
2 k8s告警模板
operator自带一些规则
参考简单k8s模板
https://awesome-prometheus-alerts.grep.to/rules#kubernetes
istio
https://awesome-prometheus-alerts.grep.to/rules#istio
更多推荐
所有评论(0)