用AI赚第一桶💰低成本搭建一套AI赚钱工具,源码可二开。 广告
[TOC] ## 配置 prometheus.yaml 方式一: ``` rule_files: - "alert.yml" ``` 方式二: ··· rule_files: - rules/*.rules ··· ## 定义告警规则 alert.yml ``` groups: - name: alert_name rules: - alert: HighErrorRate expr: job:request_latency_seconds:mean5m{job="myjob"} > 0.5 for: 10m labels: severity: page annotations: summary: High request latency description: description info ``` - alert:告警规则的名称。 - expr:基于PromQL表达式告警触发条件,用于计算是否有时间序列满足该条件。 - for:评估等待时间,可选参数。用于表示只有当触发条件持续一段时间后才发送告警。在等待期间新产生告警的状态为pending。 - labels:自定义标签,允许用户指定要附加到告警上的一组附加标签。 - annotations:用于指定一组附加信息,比如用于描述告警详细信息的文字等,annotations的内容在告警产生时会一同作为参数发送到Alertmanager。 ## 检验 **查看规则生效** ``` http://192.168.0.229:9090/rules ``` ![](https://www.aneasystone.com/usr/uploads/2018/10/1285663259.jpg) <br/> **查看警告生效** ``` http://192.168.0.229:9090/alerts ``` ![](https://www.aneasystone.com/usr/uploads/2018/10/1360557187.jpg) 当我们停掉某个 exporter 时, State 变为FIRING