- 进入prometheus-server安装节点
- 进入prometheus配置文件目录,新建rules文件夹,该文件夹用于存放告警规则文件,并且规定文件名后缀为.yml(规则文件命名格式可以自定义,只要和prometheus.yml文件配置的rule_files匹配上即可)
- 修改prometheus.yml文件配置rule_files为"rules/*.yml"
- 在2向欧盟口岸的ris文件夹下 新建一个规则文件instance_down_rule.yml进行测试。规则文件配置如下:
groups:
- name: Test-Group-001
rules:
- alert: InstanceDown
expr: up == 0
for: 1m
labels:
severity: warning
annotations:
summary: "服务 {
{ $labels.instance }} 下线了"
description: "{
{ $labels.instance }} of job {
{ $labels.job }} has been down for more than 1 minute