Use builtin autodiscovery of alertmanager
Change-Id: I36bdb3a4e90687d32724e5e248d5862567c36f83
Depends-On: I91e23f17858deb2ef937fcd42948641eb371474b
diff --git a/prometheus/files/prometheus.yml b/prometheus/files/prometheus.yml
index dd17832..77bef08 100644
--- a/prometheus/files/prometheus.yml
+++ b/prometheus/files/prometheus.yml
@@ -5,6 +5,25 @@
{{ server.config.global | yaml(False) | indent(2, true) }}
{%- endif %}
+{%- if server.get('config', {}).get('alertmanager') %}
+alerting:
+ alertmanagers:
+ {%- for name, alertmanager in server.config.alertmanager.iteritems() %}
+ {%- if alertmanager.get('enabled', True) %}
+ # {{ name }}
+ {%- if alertmanager.static_configs is defined %}
+ - static_configs:
+ - targets: {{ alertmanager.static_configs.get('target', [])|yaml }}
+ {%- elif alertmanager.dns_sd_configs is defined %}
+ - dns_sd_configs:
+ - names: {{ alertmanager.dns_sd_configs.get('domain', [])|yaml }}
+ type: {{ alertmanager.dns_sd_configs.type }}
+ port: {{ alertmanager.dns_sd_configs.port }}
+ {%- endif %}
+ {%- endif %}
+ {%- endfor %}
+{%- endif %}
+
rule_files:
- alerts.yml
diff --git a/tests/pillar/server.sls b/tests/pillar/server.sls
index 5f2a2d2..64f31f2 100644
--- a/tests/pillar/server.sls
+++ b/tests/pillar/server.sls
@@ -68,6 +68,14 @@
evaluation_interval: "1m"
external_labels:
region: 'region1'
+ alertmanager:
+ docker_swarm_alertmanager:
+ enabled: true
+ dns_sd_configs:
+ domain:
+ - tasks.monitoring_alertmanager
+ type: A
+ port: 9093
docker:
host:
enabled: true