From 05df4e72095a4209acc8d6d15c37c6e54b937795 Mon Sep 17 00:00:00 2001
From: Mark Goddard <mark@stackhpc.com>
Date: Thu, 21 Sep 2023 12:23:24 +0100
Subject: [PATCH] prometheus: Fix etcd scrape when etcd uses TLS

Use HTTPS to scrape etcd metrics when etcd TLS is enabled.

Change-Id: Iaff10d5314a8dc5b07137d93c269f1ac24cf63de
Closes-Bug: #2036950
---
 ansible/roles/prometheus/templates/prometheus.yml.j2        | 3 +++
 .../notes/prometheus-etcd-tls-313e7cf454f6763a.yaml         | 6 ++++++
 2 files changed, 9 insertions(+)
 create mode 100644 releasenotes/notes/prometheus-etcd-tls-313e7cf454f6763a.yaml

diff --git a/ansible/roles/prometheus/templates/prometheus.yml.j2 b/ansible/roles/prometheus/templates/prometheus.yml.j2
index a67d6e77f..2aae337c0 100644
--- a/ansible/roles/prometheus/templates/prometheus.yml.j2
+++ b/ansible/roles/prometheus/templates/prometheus.yml.j2
@@ -203,6 +203,9 @@ scrape_configs:
 
 {% if enable_prometheus_etcd_integration | bool %}
   - job_name: etcd
+{% if etcd_enable_tls | bool %}
+    scheme: https
+{% endif %}
     static_configs:
 {% for host in groups["etcd"] %}
       - targets:
diff --git a/releasenotes/notes/prometheus-etcd-tls-313e7cf454f6763a.yaml b/releasenotes/notes/prometheus-etcd-tls-313e7cf454f6763a.yaml
new file mode 100644
index 000000000..67f4a2cfb
--- /dev/null
+++ b/releasenotes/notes/prometheus-etcd-tls-313e7cf454f6763a.yaml
@@ -0,0 +1,6 @@
+---
+fixes:
+  - |
+    Fixes an issue where Prometheus scraping of Etcd metrics would fail if Etcd
+    TLS is enabled. `LP#2036950
+    <https://bugs.launchpad.net/kolla-ansible/+bug/2036950>`__
-- 
GitLab