From 7b14deaf316c6c6054b33f43ffdb445adcf92629 Mon Sep 17 00:00:00 2001 From: Konstantin Hontar Date: Wed, 13 Sep 2017 14:43:46 +0300 Subject: [PATCH] Add Slack and mail receiver to AlertManager config Change-Id: Ib82ef0a7d029f84a7f92a90384bac02a0870b521 --- README.rst | 12 ++++++++++ prometheus/files/alertmanager.yml | 38 +++++++++++++++++++++++++++++++ tests/pillar/alertmanager.sls | 12 ++++++++++ 3 files changed, 62 insertions(+) diff --git a/README.rst b/README.rst index 4c126b5..c1f4498 100644 --- a/README.rst +++ b/README.rst @@ -121,6 +121,18 @@ Configure alertmanager webhook_configs: - url: http://127.0.0.1 send_resolved: true + - name: 'HTTP-slack' + slack_configs: + - api_url: http://127.0.0.1/slack + send_resolved: true + - name: 'smtp' + email_configs: + - to: test@example.com + from: test@example.com + smarthost: example.com + auth_username: username + auth_password: password + send_resolved: true Configure pushgateway --------------------- diff --git a/prometheus/files/alertmanager.yml b/prometheus/files/alertmanager.yml index 7139d48..86761de 100644 --- a/prometheus/files/alertmanager.yml +++ b/prometheus/files/alertmanager.yml @@ -76,6 +76,44 @@ receivers: send_resolved: {{ webhook.send_resolved | lower }} {%- endif %} {%- endfor %} + {%- elif config.slack_configs is defined %} + slack_configs: + {%- for name, slack in config.slack_configs.iteritems() %} + # {{ name }} + - api_url: {{ slack.api_url }} + {%- if slack.send_resolved is defined %} + send_resolved: {{ slack.send_resolved | lower }} + {%- endif %} + {%- if slack.channel is defined %} + channel: {{ slack.channel }} + {%- endif %} + {%- endfor %} + {%- elif config.email_configs is defined %} + email_configs: + {%- for name, email in config.email_configs.iteritems() %} + # {{ name }} + - to: {{ email.to }} + from: {{ email.from }} + smarthost: {{ email.smarthost }} + {%- if email.auth_username is defined %} + auth_username: '{{ email.auth_username }}' + {%- endif %} + {%- if email.auth_password is defined %} + auth_password: '{{ email.auth_password }}' + {%- endif %} + {%- if email.auth_secret is defined %} + auth_secret: '{{ email.auth_secret }}' + {%- endif %} + {%- if email.auth_identity is defined %} + auth_identity: '{{ email.auth_identity}}' + {%- endif %} + {%- if email.require_tls is defined %} + require_tls: {{ email.require_tls | lower }} + {%- endif %} + {%- if email.send_resolved is defined %} + send_resolved: {{ email.send_resolved | lower }} + {%- endif %} + {%- endfor %} {%- endif %} {%- endif %} {%- endfor %} diff --git a/tests/pillar/alertmanager.sls b/tests/pillar/alertmanager.sls index d22c28f..f15cd2c 100644 --- a/tests/pillar/alertmanager.sls +++ b/tests/pillar/alertmanager.sls @@ -38,6 +38,18 @@ prometheus: webhook_configs: - url: http://127.0.0.1 send_resolved: true + - name: 'HTTP-slack' + slack_configs: + - api_url: http://127.0.0.1/slack + send_resolved: true + - name: 'smtp' + email_configs: + - to: test@example.com + from: test@example.com + smarthost: example.com + auth_username: username + auth_password: password + send_resolved: true docker: host: enabled: true