From 23c420a55d678269930e80bc1f1afc052e061189 Mon Sep 17 00:00:00 2001 From: Piotr Milewski Date: Tue, 14 Apr 2026 09:07:08 +0200 Subject: Fix Prometheus scraping for ProxySQL and Valkey The configuration for ProxySQL and Valkey exporters was incorrectly nested inside the 'enable_prometheus_alertmanager' block. This caused the scrape jobs to be missing from prometheus.yml when Alertmanager was disabled, even if the exporters themselves were enabled. This commit moves these exporter blocks outside the Alertmanager conditional to ensure metrics are collected independently. Closes-Bug: #2148279 Change-Id: Ib4ac95cfce2272529cdc8b98c40dc7f21c50e27f Signed-off-by: Piotr Milewski --- .../roles/prometheus/templates/prometheus.yml.j2 | 40 +++++++++++----------- .../notes/bug-2148279-2ec0852b8bee0971.yaml | 8 +++++ 2 files changed, 28 insertions(+), 20 deletions(-) create mode 100644 releasenotes/notes/bug-2148279-2ec0852b8bee0971.yaml diff --git a/ansible/roles/prometheus/templates/prometheus.yml.j2 b/ansible/roles/prometheus/templates/prometheus.yml.j2 index f07e89cea..0887f9853 100644 --- a/ansible/roles/prometheus/templates/prometheus.yml.j2 +++ b/ansible/roles/prometheus/templates/prometheus.yml.j2 @@ -241,43 +241,43 @@ scrape_configs: {% endfor %} {% endif %} -{% if enable_prometheus_alertmanager | bool %} - - job_name: alertmanager +{% if enable_prometheus_proxysql_exporter | bool %} + - job_name: proxysql static_configs: -{% for host in groups['prometheus-alertmanager'] %} +{% for host in groups["loadbalancer"] %} - targets: - - '{{ 'api' | kolla_address(host, override_var='prometheus_target_address') | put_address_in_context('url') }}:{{ hostvars[host]['prometheus_alertmanager_port'] }}' + - '{{ 'api' | kolla_address(host, override_var='prometheus_target_address') | put_address_in_context('url') }}:{{ hostvars[host]['proxysql_prometheus_exporter_port'] }}' {% if hostvars[host].prometheus_instance_label | default(false, true) %} labels: instance: "{{ hostvars[host].prometheus_instance_label }}" {% endif %} {% endfor %} +{% endif %} -{% if enable_prometheus_proxysql_exporter | bool %} - - job_name: proxysql +{% if enable_prometheus_valkey_exporter | bool %} + - job_name: valkey_exporter static_configs: -{% for host in groups["loadbalancer"] %} +{% for host in groups["prometheus-valkey-exporter"] %} - targets: - - '{{ 'api' | kolla_address(host, override_var='prometheus_target_address') | put_address_in_context('url') }}:{{ hostvars[host]['proxysql_prometheus_exporter_port'] }}' -{% if hostvars[host].prometheus_instance_label | default(false, true) %} + - '{{ 'api' | kolla_address(host, override_var='prometheus_target_address') | put_address_in_context('url') }}:{{ hostvars[host]['prometheus_valkey_exporter_port'] }}' +{% if hostvars[host].prometheus_instance_label | default(false, true) %} labels: instance: "{{ hostvars[host].prometheus_instance_label }}" -{% endif %} -{% endfor %} -{% endif %} +{% endif %} +{% endfor %} +{% endif %} -{% if enable_prometheus_valkey_exporter | bool %} - - job_name: valkey_exporter +{% if enable_prometheus_alertmanager | bool %} + - job_name: alertmanager static_configs: -{% for host in groups["prometheus-valkey-exporter"] %} +{% for host in groups['prometheus-alertmanager'] %} - targets: - - '{{ 'api' | kolla_address(host, override_var='prometheus_target_address') | put_address_in_context('url') }}:{{ hostvars[host]['prometheus_valkey_exporter_port'] }}' -{% if hostvars[host].prometheus_instance_label | default(false, true) %} + - '{{ 'api' | kolla_address(host, override_var='prometheus_target_address') | 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 %} +{% endif %} +{% endfor %} alerting: alertmanagers: diff --git a/releasenotes/notes/bug-2148279-2ec0852b8bee0971.yaml b/releasenotes/notes/bug-2148279-2ec0852b8bee0971.yaml new file mode 100644 index 000000000..3e5d9c9e4 --- /dev/null +++ b/releasenotes/notes/bug-2148279-2ec0852b8bee0971.yaml @@ -0,0 +1,8 @@ +--- +fixes: + - | + Fixes an issue where Prometheus would not scrape ProxySQL or + Valkey metrics if Alertmanager was disabled. The configuration + blocks for these exporters were incorrectly nested within the + Alertmanager conditional block. + `LP#2148279 `__ -- cgit v1.2.3