普罗米修斯将警报发送到其他团队

时间:2020-07-07 12:40:37

标签: prometheus prometheus-alertmanager

我想将警报路由到警报管理器中的不同团队,以获取页面调度和空闲时间,这是我的alertmanager配置

global:
  # The smarthost and SMTP sender used for mail notifications.
  resolve_timeout: 3m
  smtp_smarthost: '127.0.0.1:25'
  smtp_require_tls: False
  smtp_from: xxx@example.com
  slack_api_url: ‘xxxx’
# The directory from which notification templates are read.
templates:
- '/templates/*.tmpl'

# The root route on which each incoming alert enters.
route:
  group_by: ['alertname', 'group']
  group_wait: 30s
  group_interval: 5m
  repeat_interval: 3h

  # A default receiver
  receiver: team-x

  routes:
  - match:
      alert_route_to: slack-notifications
    receiver: slack-notifications
receivers:
- name: 'team-x’
  email_configs:
  - to: ‘xx@example.com’

  webhook_configs:
  - url: “1.1.1.1”
    send_resolved: true

  pagerduty_configs:
  - send_resolved: true
    routing_key: xxxx
    url: https://events.pagerduty.com/v2/enqueue
    client: '{{ template "pagerduty.default.client" . }}'
    client_url: '{{ template "pagerduty.default.clientURL" . }}'
    description: '{{ template "pagerduty.default.description" .}}'
    details:
      firing: '{{ template "pagerduty.default.instances" .Alerts.Firing }}'
      num_firing: '{{ .Alerts.Firing | len }}'
      num_resolved: '{{ .Alerts.Resolved | len }}'
      resolved: '{{ template "pagerduty.default.instances" .Alerts.Resolved }}'
    severity: '{{ if .CommonLabels.severity }}{{ .CommonLabels.severity | toLower }}{{ else }}critical{{ end }}'
    group: '{{ if .CommonLabels.group }}.{{ .CommonLabels.group }}{{end }}'

- name: 'slack-notifications'
  slack_configs:
  - channel: ‘#channel’
    text: 'https://internal.myorg.net/wiki/alerts/{{ .GroupLabels.app }}/{{ .GroupLabels.alertname }}'

这是我的警报规则

groups:
- name: common rules
  rules:
  - alert: example
    expr: up == 0
    for: 15m
    labels:
      severity: warning
      alert_route_to: slack-notifications
      alert_slack_channel: #channel
    annotations:
      summary: "Prometheus exporter down (instance {{ $labels.instance }})"
      description: "Prometheus exporter down instance is down\n  VALUE = {{ $value }}\n  LABELS: {{ $labels }}"

使用此配置,我也将警惕寻呼机的工作和松弛!我不希望将闲置警报仅发送给闲置!我在这里做错了什么

0 个答案:

没有答案