From 61ff6f811abfc96045230e9f6b09f1e9c59e5432 Mon Sep 17 00:00:00 2001 From: Piotr Parczewski Date: Mon, 16 May 2022 18:07:29 +0200 Subject: [PATCH] Fix AlertManager's external web url Remove hard-coded internal address; introduce variable to control external web url. Closes-bug: #1972817 Change-Id: Ib834a9f8b4a0238960dca65b2ebc1da840cec626 --- ansible/roles/prometheus/defaults/main.yml | 2 ++ .../prometheus/templates/prometheus-alertmanager.json.j2 | 2 +- .../fix-hardcoded-alertmanager-weburl-9413b9e82a8610ea.yaml | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/fix-hardcoded-alertmanager-weburl-9413b9e82a8610ea.yaml diff --git a/ansible/roles/prometheus/defaults/main.yml b/ansible/roles/prometheus/defaults/main.yml index 9ef0ef2f1f..1757f02d7e 100644 --- a/ansible/roles/prometheus/defaults/main.yml +++ b/ansible/roles/prometheus/defaults/main.yml @@ -285,3 +285,5 @@ prometheus_memcached_exporter_cmdline_extras: "" prometheus_mysqld_exporter_cmdline_extras: "" prometheus_node_exporter_cmdline_extras: "" prometheus_openstack_exporter_cmdline_extras: "" + +prometheus_alertmanager_external_url: "{{ internal_protocol }}://{{ kolla_internal_fqdn | put_address_in_context('url') }}:{{ prometheus_alertmanager_port }}" diff --git a/ansible/roles/prometheus/templates/prometheus-alertmanager.json.j2 b/ansible/roles/prometheus/templates/prometheus-alertmanager.json.j2 index 562b910758..4e71466bfa 100644 --- a/ansible/roles/prometheus/templates/prometheus-alertmanager.json.j2 +++ b/ansible/roles/prometheus/templates/prometheus-alertmanager.json.j2 @@ -1,5 +1,5 @@ { - "command": "/opt/prometheus_alertmanager/alertmanager --config.file=/etc/prometheus/alertmanager.yml --web.listen-address={{ api_interface_address | put_address_in_context('url') }}:{{ prometheus_alertmanager_port }} --web.external-url={{ internal_protocol }}://{{ kolla_internal_fqdn | put_address_in_context('url') }}:{{ prometheus_alertmanager_port }} --cluster.listen-address={% if groups["prometheus-alertmanager"] | length > 1 %}{{ api_interface_address | put_address_in_context('url') }}:{{ prometheus_alertmanager_cluster_port }} {% for host in groups["prometheus-alertmanager"] %} --cluster.peer={{ 'api' | kolla_address(host) | put_address_in_context('url') }}:{{ hostvars[host]['prometheus_alertmanager_cluster_port'] }}{% endfor %}{% endif %} --storage.path /var/lib/prometheus", + "command": "/opt/prometheus_alertmanager/alertmanager --config.file=/etc/prometheus/alertmanager.yml --web.listen-address={{ api_interface_address | put_address_in_context('url') }}:{{ prometheus_alertmanager_port }} --web.external-url={{ prometheus_alertmanager_external_url }} --cluster.listen-address={% if groups["prometheus-alertmanager"] | length > 1 %}{{ api_interface_address | put_address_in_context('url') }}:{{ prometheus_alertmanager_cluster_port }} {% for host in groups["prometheus-alertmanager"] %} --cluster.peer={{ 'api' | kolla_address(host) | put_address_in_context('url') }}:{{ hostvars[host]['prometheus_alertmanager_cluster_port'] }}{% endfor %}{% endif %} --storage.path /var/lib/prometheus", "config_files": [ { "source": "{{ container_config_directory }}/prometheus-alertmanager.yml", diff --git a/releasenotes/notes/fix-hardcoded-alertmanager-weburl-9413b9e82a8610ea.yaml b/releasenotes/notes/fix-hardcoded-alertmanager-weburl-9413b9e82a8610ea.yaml new file mode 100644 index 0000000000..07babad9ce --- /dev/null +++ b/releasenotes/notes/fix-hardcoded-alertmanager-weburl-9413b9e82a8610ea.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fixes an issue with AlertManager external Web URL being unconfigurable. + A new variable ``prometheus_alertmanager_external_url`` has been + introduced that users can use to set web.external-url to public.