2017-03-09 06:12:27 -05:00
|
|
|
{% from "prometheus/map.jinja" import alertmanager with context %}
|
2017-06-25 08:02:42 -04:00
|
|
|
{%- macro route_entry(route={}) -%}
|
|
|
|
{%- if route.receiver is defined -%}
|
|
|
|
receiver: {{ route.receiver }}
|
|
|
|
{%- endif -%}
|
2018-03-01 07:27:21 -05:00
|
|
|
{%- if route.continue is defined %}
|
|
|
|
continue: {{ route.continue }}
|
|
|
|
{%- endif -%}
|
2017-06-25 08:02:42 -04:00
|
|
|
{%- if route.group_by is defined %}
|
|
|
|
group_by:
|
|
|
|
{%- for group_by in route.group_by %}
|
|
|
|
- {{ group_by }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if route.group_interval is defined %}
|
|
|
|
group_interval: {{ route.group_interval }}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if route.group_wait is defined %}
|
|
|
|
group_wait: {{ route.group_wait }}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if route.repeat_interval is defined %}
|
|
|
|
repeat_interval: {{ route.repeat_interval }}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if route.match_re is defined %}
|
|
|
|
match_re:
|
|
|
|
{%- for match_re in route.match_re %}
|
|
|
|
{{ match_re.label }}: {{ match_re.value }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endmacro -%}
|
|
|
|
|
2018-09-06 07:44:17 -04:00
|
|
|
{%- macro http_config_entry(http_config={}) -%}
|
|
|
|
http_config:
|
|
|
|
{%- if http_config.basic_auth is defined %}
|
|
|
|
basic_auth:
|
|
|
|
username: {{ http_config.basic_auth.username }}
|
|
|
|
password: {{ http_config.basic_auth.password }}
|
|
|
|
{%- endif %}
|
|
|
|
|
|
|
|
{%- if http_config.bearer_token is defined %}
|
|
|
|
bearer_token: {{ http_config.bearer_token }}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if http_config.bearer_token_file is defined %}
|
|
|
|
bearer_token_file: {{ http_config.bearer_token_file }}
|
|
|
|
{%- endif %}
|
|
|
|
|
|
|
|
{%- if http_config.tls_config is defined %}
|
|
|
|
tls_config:
|
|
|
|
{%- if http_config.tls_config.ca_file is defined%}
|
|
|
|
ca_file: {{ http_config.tls_config.ca_file }}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if http_config.tls_config.cert_file is defined %}
|
|
|
|
cert_file: {{ http_config.tls_config.cert_file }}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if http_config.tls_config.key_file is defined %}
|
|
|
|
key_file: {{ http_config.tls_config.key_file }}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if http_config.tls_config.server_name is defined %}
|
|
|
|
server_name: {{ http_config.tls_config.server_name }}
|
|
|
|
{%- endif %}
|
|
|
|
insecure_skip_verify: {{ http_config.tls_config.get("insecure_skip_verify", False) | lower }}
|
|
|
|
{%- endif %}
|
|
|
|
|
|
|
|
{%- if http_config.proxy_url is defined %}
|
|
|
|
proxy_url: {{ http_config.proxy_url }}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endmacro -%}
|
|
|
|
|
2017-03-09 06:12:27 -05:00
|
|
|
global:
|
|
|
|
{%- if alertmanager.config.global is defined %}
|
2017-05-12 06:49:44 -04:00
|
|
|
{%- if alertmanager.config.global.resolve_timeout is defined %}
|
|
|
|
resolve_timeout: {{ alertmanager.config.global.resolve_timeout }}
|
|
|
|
{%- endif %}
|
2018-09-06 07:44:17 -04:00
|
|
|
{%- if alertmanager.config.global.http_config is defined %}
|
|
|
|
{{ http_config_entry(alertmanager.config.global.http_config) | indent(2) }}
|
|
|
|
{%- endif %}
|
2017-03-09 06:12:27 -05:00
|
|
|
{%- endif %}
|
|
|
|
|
|
|
|
route:
|
2017-06-25 08:02:42 -04:00
|
|
|
{%- set config_route = alertmanager.config.get('route', {}) %}
|
|
|
|
{{ route_entry(config_route) | indent(2) }}
|
|
|
|
{%- if config_route.get('routes', {}) %}
|
|
|
|
routes:
|
|
|
|
{%- for route_name, route in config_route.get('routes', {}).iteritems() %}
|
|
|
|
# {{ route_name }}
|
|
|
|
- {{ route_entry(route) | indent(4) }}
|
|
|
|
{%- endfor %}
|
2017-03-09 06:12:27 -05:00
|
|
|
{%- endif %}
|
|
|
|
|
|
|
|
inhibit_rules:
|
2017-05-12 06:49:44 -04:00
|
|
|
{%- 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 %}
|
2017-03-09 06:12:27 -05:00
|
|
|
{%- endif %}
|
2017-05-12 06:49:44 -04:00
|
|
|
{%- endfor %}
|
2017-03-09 06:12:27 -05:00
|
|
|
|
|
|
|
receivers:
|
2017-05-12 06:49:44 -04:00
|
|
|
{%- 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 }}
|
2018-09-06 07:44:17 -04:00
|
|
|
send_resolved: {{ webhook.get("send_resolved", True) | lower }}
|
|
|
|
{%- if webhook.http_config is defined %}
|
|
|
|
{{ http_config_entry(webhook.http_config) | indent(6) }}
|
2017-05-12 06:49:44 -04:00
|
|
|
{%- endif %}
|
|
|
|
{%- endfor %}
|
2017-11-20 14:13:20 -05:00
|
|
|
{%- endif %}
|
|
|
|
{%- if config.slack_configs is defined %}
|
2017-09-13 07:43:46 -04:00
|
|
|
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 %}
|
2017-11-20 14:13:20 -05:00
|
|
|
{%- endif %}
|
|
|
|
{%- if config.email_configs is defined %}
|
2017-09-13 07:43:46 -04:00
|
|
|
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 %}
|
2018-03-05 08:34:51 -05:00
|
|
|
{%- if email.html is defined %}
|
|
|
|
html: '{{ email.html }}'
|
|
|
|
{%- endif %}
|
|
|
|
{%- if email.headers is defined %}
|
|
|
|
headers:
|
|
|
|
{%- for header, value in email.headers.iteritems() %}
|
|
|
|
{{ header }}: {{ value }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
2017-09-13 07:43:46 -04:00
|
|
|
{%- endfor %}
|
2017-05-12 06:49:44 -04:00
|
|
|
{%- endif %}
|
2017-03-09 06:12:27 -05:00
|
|
|
{%- endif %}
|
2017-05-12 06:49:44 -04:00
|
|
|
{%- endfor %}
|