Skip to content

Commit

Permalink
salt: Disable loki grafana dashboard if disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
ezekiel-alexrod committed Nov 7, 2024
1 parent 804ea5a commit 75ed313
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 33 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions buildchain/buildchain/salt_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
27 changes: 0 additions & 27 deletions salt/metalk8s/addons/logging/deployed/dashboards.sls

This file was deleted.

12 changes: 11 additions & 1 deletion salt/metalk8s/addons/logging/deployed/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 16 additions & 0 deletions salt/metalk8s/addons/logging/loki/deployed/dashboards.sls
Original file line number Diff line number Diff line change
@@ -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'],
}
]) }}
2 changes: 2 additions & 0 deletions salt/metalk8s/addons/logging/loki/deployed/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 4 additions & 2 deletions tests/post/steps/files/grafana_dashboard_uids.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 2 additions & 0 deletions tests/post/steps/test_monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down

0 comments on commit 75ed313

Please sign in to comment.