From 75ed313416b6ba1308a05b72e7d4c44b4c015015 Mon Sep 17 00:00:00 2001 From: Alex Rodriguez <131964409+ezekiel-alexrod@users.noreply.github.com> Date: Mon, 28 Oct 2024 12:11:44 +0100 Subject: [PATCH] salt: Disable loki grafana dashboard if disabled --- CHANGELOG.md | 4 +++ buildchain/buildchain/salt_tree.py | 6 ++--- .../addons/logging/deployed/dashboards.sls | 27 ------------------- .../metalk8s/addons/logging/deployed/init.sls | 12 ++++++++- .../logging/loki/deployed/dashboards.sls | 16 +++++++++++ .../{ => loki}/deployed/files/logs.json | 0 .../{ => loki}/deployed/files/loki.json | 0 .../addons/logging/loki/deployed/init.sls | 2 ++ .../steps/files/grafana_dashboard_uids.json | 6 +++-- tests/post/steps/test_monitoring.py | 2 ++ 10 files changed, 42 insertions(+), 33 deletions(-) delete mode 100644 salt/metalk8s/addons/logging/deployed/dashboards.sls create mode 100644 salt/metalk8s/addons/logging/loki/deployed/dashboards.sls rename salt/metalk8s/addons/logging/{ => loki}/deployed/files/logs.json (100%) rename salt/metalk8s/addons/logging/{ => loki}/deployed/files/loki.json (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59f69074a4..b54b23db7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -115,6 +115,10 @@ - Do no longer use `latest` for `storage-operator` image (PR[#4299](https://github.com/scality/metalk8s/pull/4299)) +- Loki Grafana dashboard and datasources are enabled only + if Loki is enabled. + (PR[#4464](https://github.com/scality/metalk8s/pull/4464)) + ## Release 127.0.7 (in development) ## Release 127.0.6 diff --git a/buildchain/buildchain/salt_tree.py b/buildchain/buildchain/salt_tree.py index 469cb77f11..e588befb2f 100644 --- a/buildchain/buildchain/salt_tree.py +++ b/buildchain/buildchain/salt_tree.py @@ -311,18 +311,18 @@ def task(self) -> types.TaskDict: ), Path("salt/metalk8s/addons/dex/deployed/nginx-ingress-ca-cert-configmap.sls"), Path("salt/metalk8s/addons/logging/deployed/init.sls"), - Path("salt/metalk8s/addons/logging/deployed/dashboards.sls"), Path("salt/metalk8s/addons/logging/deployed/namespace.sls"), - Path("salt/metalk8s/addons/logging/deployed/files/logs.json"), - Path("salt/metalk8s/addons/logging/deployed/files/loki.json"), Path("salt/metalk8s/addons/logging/fluent-bit/config/fluent-bit.yaml.j2"), Path("salt/metalk8s/addons/logging/fluent-bit/deployed/chart.sls"), Path("salt/metalk8s/addons/logging/fluent-bit/deployed/configmap.sls"), Path("salt/metalk8s/addons/logging/fluent-bit/deployed/init.sls"), Path("salt/metalk8s/addons/logging/fluent-bit/deployed/service-configuration.sls"), Path("salt/metalk8s/addons/logging/loki/config/loki.yaml"), + Path("salt/metalk8s/addons/logging/loki/deployed/files/logs.json"), + Path("salt/metalk8s/addons/logging/loki/deployed/files/loki.json"), Path("salt/metalk8s/addons/logging/loki/deployed/chart.sls"), Path("salt/metalk8s/addons/logging/loki/deployed/datasource.sls"), + Path("salt/metalk8s/addons/logging/loki/deployed/dashboards.sls"), Path("salt/metalk8s/addons/logging/loki/deployed/init.sls"), Path("salt/metalk8s/addons/logging/loki/deployed/loki-configuration-secret.sls"), Path("salt/metalk8s/addons/logging/loki/deployed/macro.j2"), diff --git a/salt/metalk8s/addons/logging/deployed/dashboards.sls b/salt/metalk8s/addons/logging/deployed/dashboards.sls deleted file mode 100644 index c557332811..0000000000 --- a/salt/metalk8s/addons/logging/deployed/dashboards.sls +++ /dev/null @@ -1,27 +0,0 @@ -#!jinja | metalk8s_kubernetes -{%- from "metalk8s/addons/prometheus-operator/macros.j2" - import configmaps_from_dashboards with context %} - -{{ configmaps_from_dashboards([ - { - 'name': 'logs', - 'title': 'Logs', - 'tags': ['logging'], - }, - { - 'name': 'loki', - 'title': 'Loki', - 'tags': ['logging'], - }, -]) }} - -{#- In MetalK8s 128.0 we changed the fluent-bit dashboard to use - the one from the helm chart. We need to remove the old one - to avoid conflicts. - This can be removed in `development/129.0` #} -Ensure old fluent-bit dashboard does no longer exists: - metalk8s_kubernetes.object_absent: - - name: fluent-bit-dashboard - - namespace: metalk8s-monitoring - - apiVersion: v1 - - kind: ConfigMap diff --git a/salt/metalk8s/addons/logging/deployed/init.sls b/salt/metalk8s/addons/logging/deployed/init.sls index a69944b079..32227d4e0e 100644 --- a/salt/metalk8s/addons/logging/deployed/init.sls +++ b/salt/metalk8s/addons/logging/deployed/init.sls @@ -3,4 +3,14 @@ include: - metalk8s.addons.logging.loki.deployed - metalk8s.addons.logging.fluent-bit.deployed - metalk8s.addons.prometheus-operator.deployed.namespace - - .dashboards + +{#- In MetalK8s 128.0 we changed the fluent-bit dashboard to use + the one from the helm chart. We need to remove the old one + to avoid conflicts. + This can be removed in `development/129.0` #} +Ensure old fluent-bit dashboard does no longer exists: + metalk8s_kubernetes.object_absent: + - name: fluent-bit-dashboard + - namespace: metalk8s-monitoring + - apiVersion: v1 + - kind: ConfigMap diff --git a/salt/metalk8s/addons/logging/loki/deployed/dashboards.sls b/salt/metalk8s/addons/logging/loki/deployed/dashboards.sls new file mode 100644 index 0000000000..75afe8bcaf --- /dev/null +++ b/salt/metalk8s/addons/logging/loki/deployed/dashboards.sls @@ -0,0 +1,16 @@ +#!jinja | metalk8s_kubernetes +{%- from "metalk8s/addons/prometheus-operator/macros.j2" + import configmaps_from_dashboards with context %} + +{{ configmaps_from_dashboards([ + { + 'name': 'logs', + 'title': 'Logs', + 'tags': ['logging'], + }, + { + 'name': 'loki', + 'title': 'Loki', + 'tags': ['logging'], + } +]) }} \ No newline at end of file diff --git a/salt/metalk8s/addons/logging/deployed/files/logs.json b/salt/metalk8s/addons/logging/loki/deployed/files/logs.json similarity index 100% rename from salt/metalk8s/addons/logging/deployed/files/logs.json rename to salt/metalk8s/addons/logging/loki/deployed/files/logs.json diff --git a/salt/metalk8s/addons/logging/deployed/files/loki.json b/salt/metalk8s/addons/logging/loki/deployed/files/loki.json similarity index 100% rename from salt/metalk8s/addons/logging/deployed/files/loki.json rename to salt/metalk8s/addons/logging/loki/deployed/files/loki.json diff --git a/salt/metalk8s/addons/logging/loki/deployed/init.sls b/salt/metalk8s/addons/logging/loki/deployed/init.sls index 982b3b7fce..58c54d90f5 100644 --- a/salt/metalk8s/addons/logging/loki/deployed/init.sls +++ b/salt/metalk8s/addons/logging/loki/deployed/init.sls @@ -7,6 +7,7 @@ include: - .chart - .service - .datasource + - .dashboards - .workaround-job-dep {#- Due to a bug in Loki that prevent deletion of the old chunks, @@ -45,6 +46,7 @@ Ensure Loki objects does not exist: force_absent: True - mods: - metalk8s.addons.logging.loki.deployed.chart + - metalk8s.addons.logging.loki.deployed.dashboards Ensure Loki config does not exist: metalk8s_kubernetes.object_absent: diff --git a/tests/post/steps/files/grafana_dashboard_uids.json b/tests/post/steps/files/grafana_dashboard_uids.json index 6daf5acc31..76dbfa0281 100644 --- a/tests/post/steps/files/grafana_dashboard_uids.json +++ b/tests/post/steps/files/grafana_dashboard_uids.json @@ -26,13 +26,15 @@ "Kubernetes / Proxy": "632e265de029684c40b21cb76bca4f94", "Kubernetes / Scheduler": "2e6b6a3b4bddf1427b3a55aa1311c656", "Kubernetes / Networking / Workload": "728bf77cc1166d2f3133bf25846876cc", - "Loki": "g6fe30815b172c9da7e813c15ddfe607", - "Logs": "a7e130cb82be229d6f3edbfd0a438001", "NGINX Ingress Controller": "nginx", "NGINX Ingress Request Handling Performance": "4GFbkOsZk", "Grafana Overview": "6be0s85Mk" }, "fluent-bit": { "fluent-bit": "b50980eb83fa85bca0ce83ceadaf322e09e8a4cd" + }, + "loki": { + "Loki": "g6fe30815b172c9da7e813c15ddfe607", + "Logs": "a7e130cb82be229d6f3edbfd0a438001" } } diff --git a/tests/post/steps/test_monitoring.py b/tests/post/steps/test_monitoring.py index 0e00c970c2..1623ef1ef5 100644 --- a/tests/post/steps/test_monitoring.py +++ b/tests/post/steps/test_monitoring.py @@ -549,6 +549,8 @@ def check_grafana_dashboards(host, grafana_api): expected_dashboards = expected_dashboards_json["all"] if utils.get_pillar(host, "addons:fluent-bit:enabled"): expected_dashboards.update(expected_dashboards_json["fluent-bit"]) + if utils.get_pillar(host, "addons:loki:enabled"): + expected_dashboards.update(expected_dashboards_json["loki"]) uid_mismatches = [] extra_dashboards = []