Render alertmanager config without yaml filter

Change-Id: Ie86bb95ab7bf37291347ca4533fe20bbd95484e1
This commit is contained in:
Bartosz Kupidura 2017-05-12 12:49:44 +02:00
parent 3d960a15b4
commit 953510a4d8
2 changed files with 49 additions and 13 deletions

View file

@ -11,29 +11,37 @@ parameters:
global: global:
resolve_timeout: 5m resolve_timeout: 5m
route: route:
group_by: ['alertname', 'region', 'service'] group_by: ['region', 'service']
group_wait: 60s group_wait: 60s
group_interval: 5m group_interval: 5m
repeat_interval: 3h repeat_interval: 3h
receiver: HTTP-notification receiver: HTTP-notification
inhibit_rules: inhibit_rule:
- source_match: InhibitCriticalWhenDown:
enabled: true
source_match:
severity: 'down' severity: 'down'
target_match: target_match:
severity: 'critical' severity: 'critical'
equal: ['region', 'service'] equal: ['region', 'service']
- source_match: InhibitWarningWhenDown:
enabled: true
source_match:
severity: 'down' severity: 'down'
target_match: target_match:
severity: 'warning' severity: 'warning'
equal: ['region', 'service'] equal: ['region', 'service']
- source_match: InhibitWarningWhenCritical:
enabled: true
source_match:
severity: 'critical' severity: 'critical'
target_match: target_match:
severity: 'warning' severity: 'warning'
equal: ['alertname', 'region', 'service'] equal: ['alertname', 'region', 'service']
receivers: receiver:
- name: 'HTTP-notification' HTTP-notification:
enabled: true
webhook_configs: webhook_configs:
- url: http://127.0.0.1 localhost:
url: http://127.0.0.1
send_resolved: true send_resolved: true

View file

@ -1,7 +1,9 @@
{% from "prometheus/map.jinja" import alertmanager with context %} {% from "prometheus/map.jinja" import alertmanager with context %}
global: global:
{%- if alertmanager.config.global is defined %} {%- 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 %} {%- endif %}
route: route:
@ -10,11 +12,37 @@ route:
{%- endif %} {%- endif %}
inhibit_rules: inhibit_rules:
{%- if alertmanager.config.inhibit_rules is defined %} {%- for name, rule in alertmanager.config.get('inhibit_rule', {}).iteritems() %}
{{ alertmanager.config.inhibit_rules | yaml(False) | indent(2, true) }} {%- 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 %} {%- endif %}
{%- endfor %}
receivers: receivers:
{%- if alertmanager.config.receivers is defined %} {%- for name, config in alertmanager.config.get('receiver', {}).iteritems() %}
{{ alertmanager.config.receivers | yaml(False) | indent(2, true) }} {%- 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 %} {%- endif %}
{%- endfor %}
{%- endif %}
{%- endif %}
{%- endfor %}