From 9afc9da22621cc808287874915ab3c1305592d15 Mon Sep 17 00:00:00 2001
From: Dawud <dawud@stackhpc.com>
Date: Fri, 15 Mar 2024 10:49:51 +0000
Subject: [PATCH] Update Grafana OpenSearch datasource configuration

Updates the Grafana OpenSearch datasource configuration to use values
for OpenSearch that work out of the box.

Closes-Bug: #2039500
Change-Id: Id9c7e59e6ae1dd98176c68b14a2aff1985306751
---
 ansible/roles/grafana/defaults/main.yml               |  6 +++---
 ...rch-datasource-configuration-04202c059f1abd05.yaml | 11 +++++++++++
 2 files changed, 14 insertions(+), 3 deletions(-)
 create mode 100644 releasenotes/notes/grafana-opensearch-datasource-configuration-04202c059f1abd05.yaml

diff --git a/ansible/roles/grafana/defaults/main.yml b/ansible/roles/grafana/defaults/main.yml
index 030d583346..77f24ca5e3 100644
--- a/ansible/roles/grafana/defaults/main.yml
+++ b/ansible/roles/grafana/defaults/main.yml
@@ -65,9 +65,9 @@ grafana_data_sources:
       access: "proxy"
       url: "{{ opensearch_internal_endpoint }}"
       jsonData:
-        flavor: "elasticsearch"
-        database: "[flog-]YYYY.MM.DD"
-        version: "7.0.0"
+        flavor: "OpenSearch"
+        database: "{{ opensearch_log_index_prefix }}-*"
+        version: "2.11.1"
         timeField: "@timestamp"
 
 ##########
diff --git a/releasenotes/notes/grafana-opensearch-datasource-configuration-04202c059f1abd05.yaml b/releasenotes/notes/grafana-opensearch-datasource-configuration-04202c059f1abd05.yaml
new file mode 100644
index 0000000000..4b966b144a
--- /dev/null
+++ b/releasenotes/notes/grafana-opensearch-datasource-configuration-04202c059f1abd05.yaml
@@ -0,0 +1,11 @@
+---
+fixes:
+  - |
+    Updates the default Grafana OpenSearch datasource configuration to use
+    values for OpenSearch that work out of the box. Replaces the Elasticsearch
+    values that were previously being used. The new configuration can be
+    applied by deleting your datasource and reconfiguring Grafana through kolla
+    ansible. In order to prevent dashboards from breaking when the datasource
+    is deleted, one should use `datasource variables
+    <https://grafana.com/docs/grafana/latest/dashboards/variables/add-template-variables/#add-a-data-source-variable>`__
+    in Grafana. See bug `2039500 <https://bugs.launchpad.net/kolla-ansible/+bug/2039500>`__.