From 10f0e9ddef68b1ba607a462650d07147d1fd6b19 Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Mon, 30 Oct 2023 14:47:09 +0000 Subject: [PATCH] prometheus: Add friendly instance labels for ironic and alertmanager These were omitted from I387c9d8f5c01baf6054381834ecf4e554d0fff35 and I387c9d8f5c01baf6054381834ecf4e554d0fff35. Closes-Bug: #2041855 Change-Id: I25e5450d1caeebd9c900c190fc0079988f1ca574 --- ansible/roles/prometheus/templates/prometheus.yml.j2 | 8 ++++++++ .../notes/prom-friendly-label-fix-dc665f81a0aa1081.yaml | 6 ++++++ 2 files changed, 14 insertions(+) create mode 100644 releasenotes/notes/prom-friendly-label-fix-dc665f81a0aa1081.yaml diff --git a/ansible/roles/prometheus/templates/prometheus.yml.j2 b/ansible/roles/prometheus/templates/prometheus.yml.j2 index 9cb76ab4b8..e56bb19ab4 100644 --- a/ansible/roles/prometheus/templates/prometheus.yml.j2 +++ b/ansible/roles/prometheus/templates/prometheus.yml.j2 @@ -226,6 +226,10 @@ scrape_configs: static_configs: {% for host in groups['ironic-conductor'] %} - targets: ["{{ 'api' | kolla_address(host) | put_address_in_context('url') }}:{{ hostvars[host]['ironic_prometheus_exporter_port'] }}"] +{% if hostvars[host].prometheus_instance_label | default(false, true) %} + labels: + instance: "{{ hostvars[host].prometheus_instance_label }}" +{% endif %} {% endfor %} {% endif %} @@ -247,5 +251,9 @@ alerting: - targets: {% for host in groups["prometheus-alertmanager"] %} - '{{ 'api' | kolla_address(host) | put_address_in_context('url') }}:{{ hostvars[host]['prometheus_alertmanager_port'] }}' +{% if hostvars[host].prometheus_instance_label | default(false, true) %} + labels: + instance: "{{ hostvars[host].prometheus_instance_label }}" +{% endif %} {% endfor %} {% endif %} diff --git a/releasenotes/notes/prom-friendly-label-fix-dc665f81a0aa1081.yaml b/releasenotes/notes/prom-friendly-label-fix-dc665f81a0aa1081.yaml new file mode 100644 index 0000000000..8810faffaa --- /dev/null +++ b/releasenotes/notes/prom-friendly-label-fix-dc665f81a0aa1081.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Adds missing support for friendly labels for Prometheus Ironic exporter and + Alertmanager metrics. `LP#2041855 + `__