Я посмотрел на этот вопрос / ответ здесь: Prometheus AlertManager - Отправлять оповещения различным клиентам на основе маршрутов
И это было довольно хорошее начало для меня, и я хотел бы прокомментировать быстрый ответ там, но у меня нет представителя.
В любом случае, у меня есть файл alert.rules.yml с двумя группами, который выглядит следующим образом:
groups:
- name: DevOpsAlerts
rules:
- alert: InstanceDown
expr: up == 0
for: 5m
labels:
severity: critical
annotations:
summary: "Instance {{ $labels.instance }} down"
description: "{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 5 minutes. ({{ $value }} minutes)"
- alert: InstanceHighCpu
expr: 100 - (avg by (host) (irate(node_cpu{mode="idle"}[5m])) * 100) > 5
for: 10m
labels:
severity: critical
annotations:
summary: "Instance {{ $labels.host }}: CPU High"
description: "{{ $labels.host }} has high CPU activity"
- name: TestTeam2
rules:
- alert: - alert: InstanceLowMemory
expr: node_memory_MemAvailable < 268435456
for: 10m
labels:
severity: critical
annotations:
summary: "Instance {{ $labels.host }}: memory low"
description: "{{ $labels.host }} has less than 256M memory available"
- alert: InstanceLowDisk
expr: node_filesystem_avail{mountpoint="/"} < 1073741824
for: 10m
labels:
severity: critical
annotations:
summary: "Instance {{ $labels.host }}: low disk space"
description: "{{ $labels.host }} has less than 1G FS space"
Наряду с этим у меня есть файл alertmanager.yml , который выглядит как
global:
smtp_smarthost: 'smtpserver'
smtp_from: 'alertsender@email.com'
smtp_auth_username: 'alertsender@email.com'
smtp_auth_password: 'verystrongpassword'
smtp_require_tls: maybe
route:
group_by: ['alertname', 'cluster', 'service']
#default receiver
receiver: DevOps
routes:
- match:
alertname: InstanceDown
receiver: DevOps
- match:
group: InstanceHighCpu
receiver: test-team-1
inhibit_rules:
- source_match:
severity: 'critical'
target_match:
severity: 'warning'
equal: ['alertname', 'cluster', 'service']
receivers:
- name: DevOps
email_configs:
# - to: devops_dude@email.com
- name: test-team-1
email_configs:
- to: test-dude1@email.com #This can be any email specified from the team
- name: team-name-2
email_configs:
- to: test_email@test.com #This can be any email specified from the team
Итак, из того, что я собрал, я могу направлять оповещения конкретным группам получателей, указав имя оповещения из файла правил оповещений и направив его конкретному получателю.
Большой вопрос, который у меня действительно возникает: есть ли способ направлять оповещения конкретным получателям на основе имен групп , а не имен оповещений из файла правил оповещений.
Так что вместо
routes:
- match:
alertname: InstanceDown
receiver: DevOps
Есть ли какой-то способ реализации:
routes:
- match:
group: DevOpsAlerts
receiver: DevOps
Я искал в интернете какой-то подобный пример, но ничего не смог найти. Спасибо.