From 2bafbeedd72e4d3c02da56cf361f98e50382ce13 Mon Sep 17 00:00:00 2001 From: Georg Pfuetzenreuter Date: Wed, 15 Feb 2023 20:59:46 +0100 Subject: Manage Prometheus targets Signed-off-by: Georg Pfuetzenreuter --- salt/profile/prometheus/targets.sls | 18 ++++++++++++++++++ salt/role/monitoring/prometheus-alertmanager.sls | 2 +- salt/role/monitoring/prometheus-exporter-blackbox.sls | 2 +- salt/role/monitoring/prometheus.sls | 1 + 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 salt/profile/prometheus/targets.sls diff --git a/salt/profile/prometheus/targets.sls b/salt/profile/prometheus/targets.sls new file mode 100644 index 0000000..5f29e73 --- /dev/null +++ b/salt/profile/prometheus/targets.sls @@ -0,0 +1,18 @@ +{%- set mypillar = salt['pillar.get']('profile:prometheus:targets') %} +{%- set targetsdir = '/etc/prometheus/targets' %} + +{%- if mypillar | length %} +{{ targetsdir }}: + file.directory: + - group: prometheus + +{%- for group, nodes in mypillar.items() %} +{{ targetsdir }}/{{ group }}.json: + file.serialize: + - dataset: {{ nodes }} + - serializer: json +{%- endfor %} + +{%- else %} +{%- do salt.log.debug('profile.prometheus: no targets defined') %} +{%- endif %} diff --git a/salt/role/monitoring/prometheus-alertmanager.sls b/salt/role/monitoring/prometheus-alertmanager.sls index 017d914..adf0b70 100644 --- a/salt/role/monitoring/prometheus-alertmanager.sls +++ b/salt/role/monitoring/prometheus-alertmanager.sls @@ -1,2 +1,2 @@ include: - - .prometheus + - prometheus.config diff --git a/salt/role/monitoring/prometheus-exporter-blackbox.sls b/salt/role/monitoring/prometheus-exporter-blackbox.sls index 017d914..adf0b70 100644 --- a/salt/role/monitoring/prometheus-exporter-blackbox.sls +++ b/salt/role/monitoring/prometheus-exporter-blackbox.sls @@ -1,2 +1,2 @@ include: - - .prometheus + - prometheus.config diff --git a/salt/role/monitoring/prometheus.sls b/salt/role/monitoring/prometheus.sls index adf0b70..9a96176 100644 --- a/salt/role/monitoring/prometheus.sls +++ b/salt/role/monitoring/prometheus.sls @@ -1,2 +1,3 @@ include: - prometheus.config + - profile.prometheus.targets -- cgit v1.2.3