OpenShift Prometheus添加Alert Rules

Prometheus和Openshift
  1. prometheus.yml配置中绑定alertmanager服务
......
alerting:
  alertmanagers:
  - scheme: http
    static_configs:
    - targets:
      - "localhost:9093"
  1. prometheus.rules设置prometheus告警规则
...
rules:
- alert: TooManyPods
  expr: kuberlet_running_pod_count > 10
  for: 2m
  labels:
    team: node
  annotations:
    summary: "{{$labels.instance}}: has {{$value}} pods"
    description: "{{$labels.instance}} be cateful"

规则:kuberlet_running_pod_count指标持续2分钟超过10,则发出告警。

  1. AlertManager中设置告警接收器alertmanager.yml
global:
  smtp_smarthost: 'mail.xx.com:25'
  smtp_from: '[email protected]'
  smtp_auth_username: '[email protected]'
  smtp_auth_password: 'password'
  smtp_require_tls: false
route:
  group_by: ['alertname']
  receiver: alert-email
receivers:
- name: alert-email
  email_configs:
  - to: '[email protected]'
    send_resolved: true

你可能感兴趣的:(OpenShift Prometheus添加Alert Rules)