快捷搜索:  汽车  科技

prometheus 监控磁盘容量:深入浅出监控神器Prometheus

prometheus 监控磁盘容量:深入浅出监控神器Prometheusprometheus已经触发告警:global: smtp_smarthost: 'smtp.qq.com:465' smtp_from: 'xxxx@qq.com' smtp_auth_username: 'xxxx@qq.com' smtp_auth_password: 'xxxx' smtp_require_tls: false route: group_interval: 1m repeat_interval: 1m receiver: 'mail-receiver' # group_by //采用哪个标签作为分组 # group_wait //分组等待的时间,收到报警不是立马发送出去,而是等待一段时间,看看同一组中

仪表盘编辑完后,可以导出对应的 json 文件,方便下次导入同样的仪表盘:

prometheus 监控磁盘容量:深入浅出监控神器Prometheus(1)

以上是我之前搭建的仪表盘:

prometheus 监控磁盘容量:深入浅出监控神器Prometheus(2)

七、监控告警

AlertManager是prometheus提供的告警信息下发组件,包含了对告警信息的分组,下发,静默等策略。配置完成后可以在webui上看到对应的告警策略信息。告警规则也是基于PromQL进行定制的。

编写告警配置:当Http_srv这个服务挂了,Prometheus采集不到指标,并且持续时间1分钟,就会触发告警

groups: - name: simulator-alert-rule rules: - alert: HttpSimulatorDown expr: sum(up{job="http_srv"}) == 0 for: 1m labels: severity: critical

在prometheus.yml中配置告警配置文件,需要配置上alertmanager的地址和告警文件的地址

# Alertmanager configuration alerting: alertmanagers: - static_configs: - targets: ['localhost:9093'] # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. rule_files: - "alert_rules.yml" #- "first_rules.yml"

配置告警信息,例如告警发送地址,告警内容模版,分组策略等都在alertmanager的配置文件中配置:

global: smtp_smarthost: 'smtp.qq.com:465' smtp_from: 'xxxx@qq.com' smtp_auth_username: 'xxxx@qq.com' smtp_auth_password: 'xxxx' smtp_require_tls: false route: group_interval: 1m repeat_interval: 1m receiver: 'mail-receiver' # group_by //采用哪个标签作为分组 # group_wait //分组等待的时间,收到报警不是立马发送出去,而是等待一段时间,看看同一组中是否有其他报警,如果有一并发送 # group_interval //告警时间间隔 # repeat_interval //重复告警时间间隔,可以减少发送告警的频率 # receiver //接收者是谁 # routes //子路由配置 receivers: - name: 'mail-receiver' email_configs: - to: 'xxxx@qq.com'

当我kill进程:

prometheus 监控磁盘容量:深入浅出监控神器Prometheus(3)

prometheus已经触发告警:

prometheus 监控磁盘容量:深入浅出监控神器Prometheus(4)

在等待1分钟,如果持续还是符合告警策略,则状态为从pending变为FIRING会发送邮件到我的邮箱

prometheus 监控磁盘容量:深入浅出监控神器Prometheus(5)

猜您喜欢: