From 666bac28d9d345351f82f7dd7e5262fad7b0471f Mon Sep 17 00:00:00 2001 From: Kaviraj Kanagaraj Date: Mon, 13 Jun 2022 12:57:44 +0200 Subject: [PATCH] Revert "Loki Prometheus mixin: templatize cluster label" (#6377) * Revert "Loki Prometheus mixin: templatize cluster label (#6353)" This reverts commit 459036f9f9bbb29fcae501bf2f0c2d53608ff3ea. * Replace `loki-mixin` dependency to working commit. Signed-off-by: Kaviraj --- production/loki-mixin/config.libsonnet | 1 - .../dashboards/dashboard-utils.libsonnet | 20 +++++++++---------- .../dashboards/loki-chunks.libsonnet | 2 +- .../loki-mixin/dashboards/loki-logs.libsonnet | 10 +++++----- .../dashboards/loki-operational.libsonnet | 8 ++++---- .../dashboards/loki-reads.libsonnet | 2 +- .../dashboards/loki-writes.libsonnet | 2 +- production/promtail-mixin/jsonnetfile.json | 2 +- 8 files changed, 23 insertions(+), 24 deletions(-) diff --git a/production/loki-mixin/config.libsonnet b/production/loki-mixin/config.libsonnet index 63e904feb354..220325c80306 100644 --- a/production/loki-mixin/config.libsonnet +++ b/production/loki-mixin/config.libsonnet @@ -8,6 +8,5 @@ // The label used to differentiate between different nodes (i.e. servers). per_node_label: 'instance', - per_cluster_label: 'cluster', }, } diff --git a/production/loki-mixin/dashboards/dashboard-utils.libsonnet b/production/loki-mixin/dashboards/dashboard-utils.libsonnet index 4b8a9fbf56c5..1999c966b0d5 100644 --- a/production/loki-mixin/dashboards/dashboard-utils.libsonnet +++ b/production/loki-mixin/dashboards/dashboard-utils.libsonnet @@ -29,15 +29,15 @@ local utils = import 'mixin-utils/utils.libsonnet'; addCluster(multi=false):: if multi then - self.addMultiTemplate('cluster', 'loki_build_info', $._config.per_cluster_label) + self.addMultiTemplate('cluster', 'loki_build_info', 'cluster') else - self.addTemplate('cluster', 'loki_build_info', $._config.per_cluster_label), + self.addTemplate('cluster', 'loki_build_info', 'cluster'), addNamespace(multi=false):: if multi then - self.addMultiTemplate('namespace', 'loki_build_info{' + $._config.per_cluster_label + '=~"$cluster"}', 'namespace') + self.addMultiTemplate('namespace', 'loki_build_info{cluster=~"$cluster"}', 'namespace') else - self.addTemplate('namespace', 'loki_build_info{' + $._config.per_cluster_label + '=~"$cluster"}', 'namespace'), + self.addTemplate('namespace', 'loki_build_info{cluster=~"$cluster"}', 'namespace'), addTag():: self + { @@ -74,18 +74,18 @@ local utils = import 'mixin-utils/utils.libsonnet'; }; if multi then - d.addMultiTemplate('cluster', 'loki_build_info', $._config.per_cluster_label) - .addMultiTemplate('namespace', 'loki_build_info{' + $._config.per_cluster_label + '=~"$cluster"}', 'namespace') + d.addMultiTemplate('cluster', 'loki_build_info', 'cluster') + .addMultiTemplate('namespace', 'loki_build_info{cluster=~"$cluster"}', 'namespace') else - d.addTemplate('cluster', 'loki_build_info', $._config.per_cluster_label) - .addTemplate('namespace', 'loki_build_info{' + $._config.per_cluster_label + '=~"$cluster"}', 'namespace'), + d.addTemplate('cluster', 'loki_build_info', 'cluster') + .addTemplate('namespace', 'loki_build_info{cluster=~"$cluster"}', 'namespace'), }, jobMatcher(job):: - $._config.per_cluster_label + '=~"$cluster", job=~"($namespace)/%s"' % job, + 'cluster=~"$cluster", job=~"($namespace)/%s"' % job, namespaceMatcher():: - $._config.per_cluster_label + '=~"$cluster", namespace=~"$namespace"', + 'cluster=~"$cluster", namespace=~"$namespace"', containerLabelMatcher(containerName):: 'label_name=~"%s.*"' % containerName, diff --git a/production/loki-mixin/dashboards/loki-chunks.libsonnet b/production/loki-mixin/dashboards/loki-chunks.libsonnet index 2056be14053d..d9e877184033 100644 --- a/production/loki-mixin/dashboards/loki-chunks.libsonnet +++ b/production/loki-mixin/dashboards/loki-chunks.libsonnet @@ -6,7 +6,7 @@ local utils = import 'mixin-utils/utils.libsonnet'; local dashboards = self, 'loki-chunks.json': { local cfg = self, - labelsSelector:: $._config.per_cluster_label + '="$cluster", job="$namespace/ingester"', + labelsSelector:: 'cluster="$cluster", job="$namespace/ingester"', } + $.dashboard('Loki / Chunks', uid='chunks') .addCluster() diff --git a/production/loki-mixin/dashboards/loki-logs.libsonnet b/production/loki-mixin/dashboards/loki-logs.libsonnet index 6e0eb8406330..5f7d2eed4386 100644 --- a/production/loki-mixin/dashboards/loki-logs.libsonnet +++ b/production/loki-mixin/dashboards/loki-logs.libsonnet @@ -7,7 +7,7 @@ local template = import 'grafonnet/template.libsonnet'; template.new( 'deployment', '$datasource', - 'label_values(kube_deployment_created{' + $._config.per_cluster_label + '="$cluster", namespace="$namespace"}, deployment)', + 'label_values(kube_deployment_created{cluster="$cluster", namespace="$namespace"}, deployment)', sort=1, ), @@ -15,7 +15,7 @@ local template = import 'grafonnet/template.libsonnet'; template.new( 'pod', '$datasource', - 'label_values(kube_pod_container_info{' + $._config.per_cluster_label + '="$cluster", namespace="$namespace", pod=~"$deployment.*"}, pod)', + 'label_values(kube_pod_container_info{cluster="$cluster", namespace="$namespace", pod=~"$deployment.*"}, pod)', sort=1, ), @@ -23,7 +23,7 @@ local template = import 'grafonnet/template.libsonnet'; template.new( 'container', '$datasource', - 'label_values(kube_pod_container_info{' + $._config.per_cluster_label + '="$cluster", namespace="$namespace", pod=~"$pod", pod=~"$deployment.*"}, container)', + 'label_values(kube_pod_container_info{cluster="$cluster", namespace="$namespace", pod=~"$pod", pod=~"$deployment.*"}, container)', sort=1, ), @@ -48,7 +48,7 @@ local template = import 'grafonnet/template.libsonnet'; local cfg = self, showMultiCluster:: true, - clusterLabel:: $._config.per_cluster_label, + clusterLabel:: 'cluster', } + lokiLogs + $.dashboard('Loki / Logs', uid='logs') @@ -62,7 +62,7 @@ local template = import 'grafonnet/template.libsonnet'; targets: [ e { expr: if dashboards['loki-logs.json'].showMultiCluster then super.expr - else std.strReplace(super.expr, $._config.per_cluster_label + '="$cluster", ', ''), + else std.strReplace(super.expr, 'cluster="$cluster", ', ''), } for e in p.targets ], diff --git a/production/loki-mixin/dashboards/loki-operational.libsonnet b/production/loki-mixin/dashboards/loki-operational.libsonnet index 75a2d358afc1..78efdbb96cac 100644 --- a/production/loki-mixin/dashboards/loki-operational.libsonnet +++ b/production/loki-mixin/dashboards/loki-operational.libsonnet @@ -11,7 +11,7 @@ local utils = import 'mixin-utils/utils.libsonnet'; showAnnotations:: true, showLinks:: true, showMultiCluster:: true, - clusterLabel:: $._config.per_cluster_label, + clusterLabel:: 'cluster', matchers:: { cortexgateway: [utils.selector.re('job', '($namespace)/cortex-gw')], @@ -44,13 +44,13 @@ local utils = import 'mixin-utils/utils.libsonnet'; std.strReplace( std.strReplace( expr, - ', ' + $._config.per_cluster_label + '="$cluster"', + ', cluster="$cluster"', '' ), - ', ' + $._config.per_cluster_label + '=~"$cluster"', + ', cluster=~"$cluster"', '' ), - $._config.per_cluster_label + '="$cluster",', + 'cluster="$cluster",', '' ), diff --git a/production/loki-mixin/dashboards/loki-reads.libsonnet b/production/loki-mixin/dashboards/loki-reads.libsonnet index f74d1da1eccd..ecb6bf543dcb 100644 --- a/production/loki-mixin/dashboards/loki-reads.libsonnet +++ b/production/loki-mixin/dashboards/loki-reads.libsonnet @@ -11,7 +11,7 @@ local utils = import 'mixin-utils/utils.libsonnet'; local cfg = self, showMultiCluster:: true, - clusterLabel:: $._config.per_cluster_label, + clusterLabel:: 'cluster', clusterMatchers:: if cfg.showMultiCluster then [utils.selector.re(cfg.clusterLabel, '$cluster')] diff --git a/production/loki-mixin/dashboards/loki-writes.libsonnet b/production/loki-mixin/dashboards/loki-writes.libsonnet index fcdfa7104503..b5133ce2bf69 100644 --- a/production/loki-mixin/dashboards/loki-writes.libsonnet +++ b/production/loki-mixin/dashboards/loki-writes.libsonnet @@ -8,7 +8,7 @@ local utils = import 'mixin-utils/utils.libsonnet'; local cfg = self, showMultiCluster:: true, - clusterLabel:: $._config.per_cluster_label, + clusterLabel:: 'cluster', clusterMatchers:: if cfg.showMultiCluster then [utils.selector.re(cfg.clusterLabel, '$cluster')] diff --git a/production/promtail-mixin/jsonnetfile.json b/production/promtail-mixin/jsonnetfile.json index ea5523c5f9f0..06cabe7ef51e 100644 --- a/production/promtail-mixin/jsonnetfile.json +++ b/production/promtail-mixin/jsonnetfile.json @@ -26,7 +26,7 @@ "subdir": "production/loki-mixin" } }, - "version": "main" + "version": "aed11c25e" } ], "legacyImports": true