summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2024-08-07 17:35:38 +0200
committerChristian Pointner <equinox@spreadspace.org>2024-08-07 17:35:38 +0200
commitdd1143e03a3c84a89956df3ccaec64ea77f3ca95 (patch)
treea03a33a1d90feeb28fdb64595b30d74707cfa692
parentonly create grafana-dashboard sub-dirs once... (diff)
prometheus: make instance name for scraping alertmanager metrics configurable
-rw-r--r--inventory/host_vars/ch-mon.yml1
-rw-r--r--inventory/host_vars/ele-calypso.yml1
-rw-r--r--roles/monitoring/prometheus/server/defaults/main/main.yml3
-rw-r--r--roles/monitoring/prometheus/server/templates/prometheus.yml.j24
4 files changed, 7 insertions, 2 deletions
diff --git a/inventory/host_vars/ch-mon.yml b/inventory/host_vars/ch-mon.yml
index acb2d15f..b93dbd05 100644
--- a/inventory/host_vars/ch-mon.yml
+++ b/inventory/host_vars/ch-mon.yml
@@ -141,6 +141,7 @@ prometheus_server_alertmanager:
basic_auth:
username: server
password: "{{ vault_prometheus_alertmanager_auth_user_passwords['server'] }}"
+ scrape_instance: "{{ inventory_hostname }}"
prometheus_server_web_external_url: "http://mon.chaos-at-home.org/prometheus/"
diff --git a/inventory/host_vars/ele-calypso.yml b/inventory/host_vars/ele-calypso.yml
index 51c324ab..90e92097 100644
--- a/inventory/host_vars/ele-calypso.yml
+++ b/inventory/host_vars/ele-calypso.yml
@@ -101,6 +101,7 @@ prometheus_server_storage:
prometheus_server_alertmanager:
url: "127.0.0.1:9093"
path_prefix: "/alertmanager/"
+ scrape_instance: "{{ inventory_hostname }}"
prometheus_server_web_external_url: "http://{{ network.primary.address | ansible.utils.ipaddr('address') }}/prometheus/"
diff --git a/roles/monitoring/prometheus/server/defaults/main/main.yml b/roles/monitoring/prometheus/server/defaults/main/main.yml
index e94aaaf5..25cffa5b 100644
--- a/roles/monitoring/prometheus/server/defaults/main/main.yml
+++ b/roles/monitoring/prometheus/server/defaults/main/main.yml
@@ -15,7 +15,7 @@ prometheus_server_evaluation_interval: "15s"
prometheus_server_jobs:
- node
-#prometheus_server_jobs_extra: |
+#prometheus_server_jobs_extra: |-
# - job_name: ...
prometheus_server_rules:
@@ -49,6 +49,7 @@ prometheus_server_rules:
# basic_auth:
# username: server
# password: geheim
+# scrape_instance: <inventory-hostname>
prometheus_server_web_listen_address: 127.0.0.1:9090
# prometheus_server_web_route_prefix: /prometheus/
diff --git a/roles/monitoring/prometheus/server/templates/prometheus.yml.j2 b/roles/monitoring/prometheus/server/templates/prometheus.yml.j2
index 09d5452d..85adfa52 100644
--- a/roles/monitoring/prometheus/server/templates/prometheus.yml.j2
+++ b/roles/monitoring/prometheus/server/templates/prometheus.yml.j2
@@ -45,7 +45,7 @@ scrape_configs:
- targets: ['localhost:9090']
labels:
instance: '{{ inventory_hostname }}'
-{% if prometheus_server_alertmanager is defined %}
+{% if prometheus_server_alertmanager is defined and 'scrape_instance' in prometheus_server_alertmanager %}
- job_name: 'alertmanager'
{% if 'path_prefix' in prometheus_server_alertmanager %}
@@ -58,6 +58,8 @@ scrape_configs:
{% endif %}
static_configs:
- targets: ['{{ prometheus_server_alertmanager.url }}']
+ labels:
+ instance: '{{ prometheus_server_alertmanager.scrape_instance }}'
{% endif %}
{% for job in (prometheus_server_jobs) %}