From 03a1b9925d553b64aec1b23b9f51a4afbb19f95e Mon Sep 17 00:00:00 2001
From: Piotr Parczewski <piotr@stackhpc.com>
Date: Wed, 29 Nov 2023 08:29:36 +0100
Subject: [PATCH] Adjust Ceph metrics scrape interval in Prometheus

Enables modifying the interval and sets the recommended default value.

[1] https://docs.ceph.com/en/latest/mgr/prometheus/#configuration

Change-Id: I4b91d184485aa52b3c06011f9dbb6b34bcad3ca8
---
 ansible/group_vars/all.yml                                   | 1 +
 ansible/roles/prometheus/templates/prometheus.yml.j2         | 1 +
 .../add-ceph-metrics-scrape-interval-3ee39fba696860e9.yaml   | 5 +++++
 3 files changed, 7 insertions(+)
 create mode 100644 releasenotes/notes/add-ceph-metrics-scrape-interval-3ee39fba696860e9.yaml

diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml
index 6837b3adf8..0786f6ee2a 100644
--- a/ansible/group_vars/all.yml
+++ b/ansible/group_vars/all.yml
@@ -1288,6 +1288,7 @@ enable_prometheus_etcd_integration: "{{ enable_prometheus | bool and enable_etcd
 enable_prometheus_msteams: "no"
 
 prometheus_alertmanager_user: "admin"
+prometheus_ceph_exporter_interval: "{{ prometheus_scrape_interval }}"
 prometheus_grafana_user: "grafana"
 prometheus_scrape_interval: "60s"
 prometheus_openstack_exporter_interval: "{{ prometheus_scrape_interval }}"
diff --git a/ansible/roles/prometheus/templates/prometheus.yml.j2 b/ansible/roles/prometheus/templates/prometheus.yml.j2
index be4febed04..e935f15102 100644
--- a/ansible/roles/prometheus/templates/prometheus.yml.j2
+++ b/ansible/roles/prometheus/templates/prometheus.yml.j2
@@ -125,6 +125,7 @@ scrape_configs:
 {% if enable_prometheus_ceph_mgr_exporter | bool %}
   - job_name: ceph_mgr_exporter
     honor_labels: true
+    scrape_interval: {{ prometheus_ceph_exporter_interval }}
     static_configs:
       - targets:
 {% for exporter in prometheus_ceph_mgr_exporter_endpoints %}
diff --git a/releasenotes/notes/add-ceph-metrics-scrape-interval-3ee39fba696860e9.yaml b/releasenotes/notes/add-ceph-metrics-scrape-interval-3ee39fba696860e9.yaml
new file mode 100644
index 0000000000..cfd6451c83
--- /dev/null
+++ b/releasenotes/notes/add-ceph-metrics-scrape-interval-3ee39fba696860e9.yaml
@@ -0,0 +1,5 @@
+---
+features:
+  - |
+    Adds a new variable ``prometheus_ceph_exporter_interval`` for controlling
+    Ceph's metrics scrape interval.
-- 
GitLab