groups:
- name: 服务器告警
rules:- alert: 服务器宕机告警
expr: up == 0
for: 3m
annotations:
summary: "Alerting {{$labels.instance}}宕机!"
description: "环境{{$labels.job}} 服务器{{$labels.instance}}已宕机!" - alert: cpu使用率过高告警
expr: (100 - (avg(irate(node_cpu_seconds_total{mode="idle"}[5m])) by(instance)* 100))* on(instance) group_left(nodename) (node_uname_info) > 85
for: 5m
annotations:
summary: "Alerting环境{{$labels.job}} {{$labels.instance}}({{$labels.nodename}})CPU使用率过高!"
description: '服务器{{$labels.instance}}({{$labels.nodename}})CPU使用率超过85%(目前使用:{{printf "%.2f" $value}}%)' - alert: 系统负载过高
expr: (node_load1/count without (cpu, mode) (node_cpu_seconds_total{mode="system"}))* on(instance) group_left(nodename) (node_uname_info)>4
for: 3m
annotations:
summary: "Alerting环境{{$labels.job}} {{$labels.instance}}({{$labels.nodename}})系统负载过高!"
description: '{{$labels.instance}}({{$labels.nodename}})当前负载超标率 {{printf "%.2f" $value}}' - alert: 内存不足告警
expr: (100 - node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes * 100)* on(instance) group_left(nodename) (node_uname_info) > 88
for: 3m
annotations:
summary: "Alerting环境{{$labels.job}} {{$labels.instance}}({{$labels.nodename}})内存使用率过高!"
description: '服务器{{$labels.instance}}({{$labels.nodename}})内存使用率超过80%(目前使用:{{printf "%.2f" $value}}%)' - alert: 硬盘空间不足告警
expr: (100-(node_filesystem_free_bytes{fstype=~"ext4|xfs"}/node_filesystem_size_bytes {fstype=~"ext4|xfs"}100) ) on(instance) group_left(nodename) (node_uname_info)> 85
for: 3m
annotations:
summary: "Alerting环境{{$labels.job}} {{$labels.instance}}({{$labels.nodename}})硬盘使用率过高!"
description: '服务器{{$labels.instance}}({{$labels.nodename}})硬盘使用率超过80%(目前使用:{{printf "%.2f" $value}}%)' - alert: TCP连接数
expr: node_netstat_Tcp_CurrEstab > 1000
expr: (node_netstat_Tcp_CurrEstab)* on(instance) group_left(nodename) (node_uname_info) > 1000
for: 2m
annotations:
summary: "Alerting环境{{$labels.job}} {{$labels.instance}} TCP ESTABLISHED连接数过高!"
description: "{{$labels.instanceJ}} TCP_ESTABLISHED当前连接数{[ $value }"
groups:
- alert: 服务器宕机告警
- name: Docker pod
rules:- alert: DockerInstanceDown
expr: container_last_seen{image!="",id!=""} == 0
for: 1m
annotations:
description: '{{ $value.name }} {{ $labels.nodename }} of job {{ $labels.job }} has been down for more than 5 s.'
summary: 'Instance {{ $labels.instance }} down'
- alert: DockerInstanceDown