Skip to content

Commit

Permalink
Revert "Loki Prometheus mixin: templatize cluster label" (#6377)
Browse files Browse the repository at this point in the history
* Revert "Loki Prometheus mixin: templatize cluster label (#6353)"

This reverts commit 459036f.

* Replace `loki-mixin` dependency to working commit.

Signed-off-by: Kaviraj <kavirajkanagaraj@gmail.com>
  • Loading branch information
kavirajk authored Jun 13, 2022
1 parent 459036f commit 666bac2
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 24 deletions.
1 change: 0 additions & 1 deletion production/loki-mixin/config.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@

// The label used to differentiate between different nodes (i.e. servers).
per_node_label: 'instance',
per_cluster_label: 'cluster',
},
}
20 changes: 10 additions & 10 deletions production/loki-mixin/dashboards/dashboard-utils.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -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 + {
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion production/loki-mixin/dashboards/loki-chunks.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 5 additions & 5 deletions production/loki-mixin/dashboards/loki-logs.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ 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,
),

local podTemplate =
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,
),

local containerTemplate =
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,
),

Expand All @@ -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')
Expand All @@ -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
],
Expand Down
8 changes: 4 additions & 4 deletions production/loki-mixin/dashboards/loki-operational.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -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')],
Expand Down Expand Up @@ -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",',
''
),

Expand Down
2 changes: 1 addition & 1 deletion production/loki-mixin/dashboards/loki-reads.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -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')]
Expand Down
2 changes: 1 addition & 1 deletion production/loki-mixin/dashboards/loki-writes.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -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')]
Expand Down
2 changes: 1 addition & 1 deletion production/promtail-mixin/jsonnetfile.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"subdir": "production/loki-mixin"
}
},
"version": "main"
"version": "aed11c25e"
}
],
"legacyImports": true
Expand Down

0 comments on commit 666bac2

Please sign in to comment.