From 5c41b54696c1c04978da1372d84a398aad58b287 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 31 Aug 2024 16:40:26 +0200 Subject: prometheus remote-write: refactor config to force naming destinations --- roles/monitoring/prometheus/server/defaults/main/main.yml | 5 +++-- roles/monitoring/prometheus/server/templates/prometheus.yml.j2 | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'roles') diff --git a/roles/monitoring/prometheus/server/defaults/main/main.yml b/roles/monitoring/prometheus/server/defaults/main/main.yml index 61bc4323..dd290e9e 100644 --- a/roles/monitoring/prometheus/server/defaults/main/main.yml +++ b/roles/monitoring/prometheus/server/defaults/main/main.yml @@ -77,8 +77,9 @@ prometheus_server_web_listen_address: 127.0.0.1:9090 prometheus_server_remote_write_receiver: no -# prometheus_server_remote_write_config: -# - url: "https://mon.example.com/prometheus/api/v1/write" +# prometheus_server_remote_write_destinations: +# example: +# url: "https://mon.example.com/prometheus/api/v1/write" # basic_auth: # username: remote # password_file: /etc/prometheus/prometheus-remote.secret diff --git a/roles/monitoring/prometheus/server/templates/prometheus.yml.j2 b/roles/monitoring/prometheus/server/templates/prometheus.yml.j2 index cf21dc80..d72a4815 100644 --- a/roles/monitoring/prometheus/server/templates/prometheus.yml.j2 +++ b/roles/monitoring/prometheus/server/templates/prometheus.yml.j2 @@ -96,8 +96,10 @@ scrape_configs: - targets: ['{{ config.url }}'] {% endfor %} {% endfor %} -{% if prometheus_server_remote_write_config is defined %} +{% if prometheus_server_remote_write_destinations is defined %} remote_write: - {{ prometheus_server_remote_write_config | to_nice_yaml(indent=2) | indent(2) }} +{% for name, config in prometheus_server_remote_write_destinations.items() %} + - {{ config | combine({'name': name }) | to_nice_yaml(indent=2) | indent(4) }} +{% endfor %} {% endif %} -- cgit v1.2.3