diff --git a/metadata/service/alertmanager/container.yml b/metadata/service/alertmanager/container.yml index 1fcf610..8335969 100644 --- a/metadata/service/alertmanager/container.yml +++ b/metadata/service/alertmanager/container.yml @@ -11,29 +11,37 @@ parameters: global: resolve_timeout: 5m route: - group_by: ['alertname', 'region', 'service'] + group_by: ['region', 'service'] group_wait: 60s group_interval: 5m repeat_interval: 3h receiver: HTTP-notification - inhibit_rules: - - source_match: + inhibit_rule: + InhibitCriticalWhenDown: + enabled: true + source_match: severity: 'down' target_match: severity: 'critical' equal: ['region', 'service'] - - source_match: + InhibitWarningWhenDown: + enabled: true + source_match: severity: 'down' target_match: severity: 'warning' equal: ['region', 'service'] - - source_match: + InhibitWarningWhenCritical: + enabled: true + source_match: severity: 'critical' target_match: severity: 'warning' equal: ['alertname', 'region', 'service'] - receivers: - - name: 'HTTP-notification' + receiver: + HTTP-notification: + enabled: true webhook_configs: - - url: http://127.0.0.1 + localhost: + url: http://127.0.0.1 send_resolved: true diff --git a/prometheus/files/alertmanager.yml b/prometheus/files/alertmanager.yml index d699de3..793733b 100644 --- a/prometheus/files/alertmanager.yml +++ b/prometheus/files/alertmanager.yml @@ -1,7 +1,9 @@ {% from "prometheus/map.jinja" import alertmanager with context %} global: {%- if alertmanager.config.global is defined %} -{{ alertmanager.config.global | yaml(False) | indent(2, true) }} + {%- if alertmanager.config.global.resolve_timeout is defined %} + resolve_timeout: {{ alertmanager.config.global.resolve_timeout }} + {%- endif %} {%- endif %} route: @@ -10,11 +12,37 @@ route: {%- endif %} inhibit_rules: -{%- if alertmanager.config.inhibit_rules is defined %} -{{ alertmanager.config.inhibit_rules | yaml(False) | indent(2, true) }} +{%- for name, rule in alertmanager.config.get('inhibit_rule', {}).iteritems() %} +{%- if rule.get('enabled', True) %} + # {{ name }} + - source_match: + {%- for key, value in rule.source_match.iteritems() %} + {{ key }}: {{ value }} + {%- endfor %} + target_match: + {%- for key, value in rule.target_match.iteritems() %} + {{ key }}: {{ value }} + {%- endfor %} + equal: + {%- for key in rule.equal %} + - {{ key }} + {%- endfor %} {%- endif %} +{%- endfor %} receivers: -{%- if alertmanager.config.receivers is defined %} -{{ alertmanager.config.receivers | yaml(False) | indent(2, true) }} +{%- for name, config in alertmanager.config.get('receiver', {}).iteritems() %} +{%- if config.get('enabled', True) %} + - name: '{{ name }}' + {%- if config.webhook_configs is defined %} + webhook_configs: + {%- for name, webhook in config.webhook_configs.iteritems() %} + # {{ name }} + - url: {{ webhook.url }} + {%- if webhook.send_resolved is defined %} + send_resolved: {{ webhook.send_resolved | lower }} + {%- endif %} + {%- endfor %} + {%- endif %} {%- endif %} +{%- endfor %}