Manage Prometheus targets

Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
This commit is contained in:
Georg Pfuetzenreuter 2023-02-15 20:59:46 +01:00
parent 979021f5c4
commit 2bafbeedd7
Signed by: Georg
GPG Key ID: 1ED2F138E7E6FF57
4 changed files with 21 additions and 2 deletions

View File

@ -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 %}

View File

@ -1,2 +1,2 @@
include: include:
- .prometheus - prometheus.config

View File

@ -1,2 +1,2 @@
include: include:
- .prometheus - prometheus.config

View File

@ -1,2 +1,3 @@
include: include:
- prometheus.config - prometheus.config
- profile.prometheus.targets