Merge ~jacekn/charm-prometheus-alertmanager:fixes into ~prometheus-charmers/charm-prometheus-alertmanager:master

Proposed by Jacek Nykis
Status: Merged
Merged at revision: ca499e551821bd682e35bdf336541724b3e08d09
Proposed branch: ~jacekn/charm-prometheus-alertmanager:fixes
Merge into: ~prometheus-charmers/charm-prometheus-alertmanager:master
Diff against target: 219 lines (+12/-124)
2 files modified
config.yaml (+0/-26)
templates/alertmanager.yml.j2 (+12/-98)
Reviewer Review Type Date Requested Status
JuanJo Ciarlante (community) lgtm Approve
Stuart Bishop (community) Approve
Review via email: mp+322458@code.launchpad.net

Description of the change

Remove redundant enable_* config options. Rework receivers config so that alerts go to all of them not just first one

To post a comment you must log in.
Revision history for this message
Stuart Bishop (stub) wrote :

Looks good to me. I'm not familiar with alertmanager config, but the changes appear sensible and are understandable.

review: Approve
Revision history for this message
JuanJo Ciarlante (jjo) :
review: Approve (lgtm)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/config.yaml b/config.yaml
index 415ad67..04be6f7 100644
--- a/config.yaml
+++ b/config.yaml
@@ -22,74 +22,48 @@ options:
22 It's templatized to accept the following vars: {private_address},22 It's templatized to accept the following vars: {private_address},
23 {public_address}, {port}, thus you can use e.g.:23 {public_address}, {port}, thus you can use e.g.:
24 juju set alertmanager external_url="http://{private_address}:{port}/"24 juju set alertmanager external_url="http://{private_address}:{port}/"
25
26 repeat_interval:25 repeat_interval:
27 default: "30m"26 default: "30m"
28 type: string27 type: string
29 description: |28 description: |
30 If an alert has successfully been sent, wait 'repeat_interval' to29 If an alert has successfully been sent, wait 'repeat_interval' to
31 resend them.30 resend them.
32
33 smtp_smarthost:31 smtp_smarthost:
34 default: 'localhost:25'32 default: 'localhost:25'
35 type: string33 type: string
36 description: "SMTP relay"34 description: "SMTP relay"
37
38 smtp_from:35 smtp_from:
39 default: 'root@localhost'36 default: 'root@localhost'
40 type: string37 type: string
41 description: "SMTP from"38 description: "SMTP from"
42
43 smtp_to:39 smtp_to:
44 default: 'root@localhost'40 default: 'root@localhost'
45 type: string41 type: string
46 description: "Default email recipient for all alerts"42 description: "Default email recipient for all alerts"
47
48 enable_pagerduty:
49 default: False
50 type: boolean
51 description: "Enable PagerDuty notifications for critical alerts"
52
53 pagerduty_url:43 pagerduty_url:
54 default: ""44 default: ""
55 type: string45 type: string
56 description: "Override default, use default from alertmanager ( global.pagerduty_url) if unset"46 description: "Override default, use default from alertmanager ( global.pagerduty_url) if unset"
57
58 pagerduty_service_key:47 pagerduty_service_key:
59 type: string48 type: string
60 description: "PagerDuty service key"49 description: "PagerDuty service key"
61 default: ""50 default: ""
62
63 enable_slack:
64 default: False
65 type: boolean
66 description: "Enable Slack.com notifications for critical alerts, requires slack_api_url and slack_channel to be set"
67
68 slack_api_url:51 slack_api_url:
69 default: ""52 default: ""
70 type: string53 type: string
71 description: "Your slack.com Webhook URL, see https://api.slack.com/incoming-webhooks (required)"54 description: "Your slack.com Webhook URL, see https://api.slack.com/incoming-webhooks (required)"
72
73 slack_channel:55 slack_channel:
74 default: ""56 default: ""
75 type: string57 type: string
76 description: "slack channel (required)"58 description: "slack channel (required)"
77
78 enable_webhook:
79 default: False
80 type: boolean
81 description: "Enable generic webhook receiver for critical alerts"
82
83 webhook_url:59 webhook_url:
84 default: ""60 default: ""
85 type: string61 type: string
86 description: "Your webhook url"62 description: "Your webhook url"
87
88 extra_routes:63 extra_routes:
89 type: string64 type: string
90 description: "YAML string containing a list of alertmanager 'routes' to add"65 description: "YAML string containing a list of alertmanager 'routes' to add"
91 default: ""66 default: ""
92
93 extra_receivers:67 extra_receivers:
94 type: string68 type: string
95 description: "YAML string containing a list of alertmanager 'receivers' to add"69 description: "YAML string containing a list of alertmanager 'receivers' to add"
diff --git a/templates/alertmanager.yml.j2 b/templates/alertmanager.yml.j2
index 7427e78..a79f1f3 100644
--- a/templates/alertmanager.yml.j2
+++ b/templates/alertmanager.yml.j2
@@ -37,123 +37,37 @@ route:
37 # overwritten on each.37 # overwritten on each.
3838
39 routes:39 routes:
40{%- if config.enable_pagerduty and config.pagerduty_service_key is defined %}40{%- if config.pagerduty_service_key or config.slack_api_url or config.webhook_url or config.extra_receivers %}
41 - match_re:41 - receiver: juju_receiver
42 severity: critical|page
43 receiver: juju_pagerduty_receiver
44{% endif %}42{% endif %}
45{%- if config.enable_slack and config.slack_api_url is defined and config.slack_channel is defined %}43{%- if config.extra_routes %}
46 - match_re:
47 severity: critical|page
48 receiver: juju_slack_receiver
49{% endif %}
50{%- if config.enable_webhook and config.webhook_url is defined %}
51 - match_re:
52 severity: critical|page
53 receiver: juju_webhook_receiver
54{% endif %}
55{%- if config.extra_routes is defined %}
56 {{ config.extra_routes|indent(4) }}44 {{ config.extra_routes|indent(4) }}
57{% endif %}45{% endif %}
5846
59# # The child route trees.
60# routes:
61# # This routes performs a regular expression match on alert labels to
62# # catch alerts that are related to a list of services.
63# - match_re:
64# service: ^(foo1|foo2|baz)$
65# receiver: team-X-mails
66#
67# # The service has a sub-route for critical alerts, any alerts
68# # that do not match, i.e. severity != critical, fall-back to the
69# # parent node and are sent to 'team-X-mails'
70# routes:
71# - match:
72# severity: critical
73# receiver: team-X-pager
74#
75# - match:
76# service: files
77# receiver: team-Y-mails
78#
79# routes:
80# - match:
81# severity: critical
82# receiver: team-Y-pager
83#
84# # This route handles all alerts coming from a database service. If there's
85# # no team to handle it, it defaults to the DB team.
86# - match:
87# service: database
88#
89# receiver: team-DB-pager
90# # Also group alerts by affected database.
91# group_by: [alertname, cluster, database]
92#
93# routes:
94# - match:
95# owner: team-X
96# receiver: team-X-pager
97#
98# - match:
99# owner: team-Y
100# receiver: team-Y-pager
101
102# Inhibition rules allow to mute a set of alerts given that another alert is
103# firing.
104# We use this to mute any warning-level notifications if the same alert is
105# already critical.
106inhibit_rules:
107- source_match:
108 severity: 'critical'
109 target_match:
110 severity: 'warning'
111 # Apply inhibition if the alertname is the same.
112 equal: ['alertname']
113
114
115receivers:47receivers:
116- name: 'default-email-recipient'48- name: 'default-email-recipient'
117 email_configs:49 email_configs:
118 - to: '{{ config.smtp_to }}'50 - to: '{{ config.smtp_to }}'
11951{%- if config.pagerduty_service_key or config.slack_api_url or config.webhook_url or config.extra_receivers %}
120{%- if config.enable_pagerduty and config.pagerduty_service_key is defined %}52- name: 'juju_receiver'
121- name: juju_pagerduty_receiver53{%- if config.pagerduty_service_key %}
122 pagerduty_configs:54 pagerduty_configs:
123 - service_key: '{{ config.pagerduty_service_key }}'55 - service_key: '{{ config.pagerduty_service_key }}'
124{%- if config.pagerduty_url %}56{%- if config.pagerduty_url %}
125 - url: '{{ config.pagerduty_url }}'57 url: '{{ config.pagerduty_url }}'
126{% endif %}58{% endif %}
127{% endif %}59{% endif %}
128{%- if config.enable_slack and config.slack_api_url is defined and config.slack_channel is defined %}60{%- if config.slack_api_url and config.slack_channel %}
129- name: juju_slack_receiver
130 slack_configs:61 slack_configs:
131 - api_url: '{{ config.slack_api_url }}'62 - api_url: '{{ config.slack_api_url }}'
132 channel: '{{ config.slack_channel }}'63 channel: '{{ config.slack_channel }}'
133{% endif %}64{% endif %}
134{%- if config.enable_webhook and config.webhook_url is defined %}65{%- if config.webhook_url %}
135- name: juju_webhook_receiver
136 webhook_configs:66 webhook_configs:
137 - url: '{{ config.webhook_url }}'67 - url: '{{ config.webhook_url }}'
138{% endif %}68{% endif %}
139{%- if config.extra_receivers is defined %}69{%- if config.extra_receivers %}
140{{ config.extra_receivers }}70{{ config.extra_receivers|indent(2) }}
71{% endif %}
141{% endif %}72{% endif %}
14273
143# - name: 'team-X-pager'
144# email_configs:
145# - to: 'team-X+alerts-critical@example.org'
146# pagerduty_configs:
147# - service_key: <team-X-key>
148#
149# - name: 'team-Y-mails'
150# email_configs:
151# - to: 'team-Y+alerts@example.org'
152#
153# - name: 'team-Y-pager'
154# pagerduty_configs:
155# - service_key: <team-Y-key>
156#
157# - name: 'team-DB-pager'
158# pagerduty_configs:
159# - service_key: <team-DB-key>

Subscribers

People subscribed via source and target branches