kubernetes-monitoring / kubernetes-mixin

A set of Grafana dashboards and Prometheus alerts for Kubernetes.
Apache License 2.0
2.12k stars 597 forks source link

fix: multi-cluster.libsonnet to support grafana dashboard join "byField" Selector #966

Closed danushadhitya closed 1 month ago

danushadhitya commented 3 months ago

Since, most of the selectors for the dashboard are overriden by custom variables.

File in path: dashboards/resources/multi-cluster.libsonnet does have the tranformation "byField" Selector hardcoded as "cluster" but whereas all other clustername selectors use the override variable "%(clusterLabel)s". This fork contains the change of converting hard-coded selector to over-ride selector which supports grafana dashboard.

n888 commented 3 months ago

Hi @danushadhitya, thank you for the PR.

I'm seeing an interpolation issue, which could be related to how withOptions fields are parsed, could you try this ?

byField: std.format('%s', $._config.clusterLabel)

danushadhitya commented 3 months ago

Thanks for the comment @n888. I have fixed it now.

n888 commented 3 months ago

LGTM

Local diff test with k8s_cluster_name clusterLabel:

index e6bb1b71..c3333fb2 100644
--- a/charts/grafana/mixin/dashboards/k8s-resources-multicluster.json
+++ b/charts/grafana/mixin/dashboards/k8s-resources-multicluster.json
@@ -354,7 +354,7 @@
                {
                   "id": "joinByField",
                   "options": {
-                     "byField": "cluster",
+                     "byField": "k8s_cluster_name",
                      "mode": "outer"
                   }
                },
@@ -542,7 +542,7 @@
                {
                   "id": "joinByField",
                   "options": {
-                     "byField": "cluster",
+                     "byField": "k8s_cluster_name",
                      "mode": "outer"
                   }
                },