Loki Prometheus mixin: templatize cluster label (#6353)

pull/6377/head
Hervé Nicol 3 years ago committed by GitHub
parent aed11c25e6
commit 459036f9f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      production/loki-mixin/config.libsonnet
  2. 20
      production/loki-mixin/dashboards/dashboard-utils.libsonnet
  3. 2
      production/loki-mixin/dashboards/loki-chunks.libsonnet
  4. 10
      production/loki-mixin/dashboards/loki-logs.libsonnet
  5. 8
      production/loki-mixin/dashboards/loki-operational.libsonnet
  6. 2
      production/loki-mixin/dashboards/loki-reads.libsonnet
  7. 2
      production/loki-mixin/dashboards/loki-writes.libsonnet

@ -8,5 +8,6 @@
// The label used to differentiate between different nodes (i.e. servers).
per_node_label: 'instance',
per_cluster_label: 'cluster',
},
}

@ -29,15 +29,15 @@ local utils = import 'mixin-utils/utils.libsonnet';
addCluster(multi=false)::
if multi then
self.addMultiTemplate('cluster', 'loki_build_info', 'cluster')
self.addMultiTemplate('cluster', 'loki_build_info', $._config.per_cluster_label)
else
self.addTemplate('cluster', 'loki_build_info', 'cluster'),
self.addTemplate('cluster', 'loki_build_info', $._config.per_cluster_label),
addNamespace(multi=false)::
if multi then
self.addMultiTemplate('namespace', 'loki_build_info{cluster=~"$cluster"}', 'namespace')
self.addMultiTemplate('namespace', 'loki_build_info{' + $._config.per_cluster_label + '=~"$cluster"}', 'namespace')
else
self.addTemplate('namespace', 'loki_build_info{cluster=~"$cluster"}', 'namespace'),
self.addTemplate('namespace', 'loki_build_info{' + $._config.per_cluster_label + '=~"$cluster"}', 'namespace'),
addTag()::
self + {
@ -74,18 +74,18 @@ local utils = import 'mixin-utils/utils.libsonnet';
};
if multi then
d.addMultiTemplate('cluster', 'loki_build_info', 'cluster')
.addMultiTemplate('namespace', 'loki_build_info{cluster=~"$cluster"}', 'namespace')
d.addMultiTemplate('cluster', 'loki_build_info', $._config.per_cluster_label)
.addMultiTemplate('namespace', 'loki_build_info{' + $._config.per_cluster_label + '=~"$cluster"}', 'namespace')
else
d.addTemplate('cluster', 'loki_build_info', 'cluster')
.addTemplate('namespace', 'loki_build_info{cluster=~"$cluster"}', 'namespace'),
d.addTemplate('cluster', 'loki_build_info', $._config.per_cluster_label)
.addTemplate('namespace', 'loki_build_info{' + $._config.per_cluster_label + '=~"$cluster"}', 'namespace'),
},
jobMatcher(job)::
'cluster=~"$cluster", job=~"($namespace)/%s"' % job,
$._config.per_cluster_label + '=~"$cluster", job=~"($namespace)/%s"' % job,
namespaceMatcher()::
'cluster=~"$cluster", namespace=~"$namespace"',
$._config.per_cluster_label + '=~"$cluster", namespace=~"$namespace"',
containerLabelMatcher(containerName)::
'label_name=~"%s.*"' % containerName,

@ -6,7 +6,7 @@ local utils = import 'mixin-utils/utils.libsonnet';
local dashboards = self,
'loki-chunks.json': {
local cfg = self,
labelsSelector:: 'cluster="$cluster", job="$namespace/ingester"',
labelsSelector:: $._config.per_cluster_label + '="$cluster", job="$namespace/ingester"',
} +
$.dashboard('Loki / Chunks', uid='chunks')
.addCluster()

@ -7,7 +7,7 @@ local template = import 'grafonnet/template.libsonnet';
template.new(
'deployment',
'$datasource',
'label_values(kube_deployment_created{cluster="$cluster", namespace="$namespace"}, deployment)',
'label_values(kube_deployment_created{' + $._config.per_cluster_label + '="$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{cluster="$cluster", namespace="$namespace", pod=~"$deployment.*"}, pod)',
'label_values(kube_pod_container_info{' + $._config.per_cluster_label + '="$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{cluster="$cluster", namespace="$namespace", pod=~"$pod", pod=~"$deployment.*"}, container)',
'label_values(kube_pod_container_info{' + $._config.per_cluster_label + '="$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:: 'cluster',
clusterLabel:: $._config.per_cluster_label,
} + 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, 'cluster="$cluster", ', ''),
else std.strReplace(super.expr, $._config.per_cluster_label + '="$cluster", ', ''),
}
for e in p.targets
],

@ -11,7 +11,7 @@ local utils = import 'mixin-utils/utils.libsonnet';
showAnnotations:: true,
showLinks:: true,
showMultiCluster:: true,
clusterLabel:: 'cluster',
clusterLabel:: $._config.per_cluster_label,
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,
', cluster="$cluster"',
', ' + $._config.per_cluster_label + '="$cluster"',
''
),
', cluster=~"$cluster"',
', ' + $._config.per_cluster_label + '=~"$cluster"',
''
),
'cluster="$cluster",',
$._config.per_cluster_label + '="$cluster",',
''
),

@ -11,7 +11,7 @@ local utils = import 'mixin-utils/utils.libsonnet';
local cfg = self,
showMultiCluster:: true,
clusterLabel:: 'cluster',
clusterLabel:: $._config.per_cluster_label,
clusterMatchers::
if cfg.showMultiCluster then
[utils.selector.re(cfg.clusterLabel, '$cluster')]

@ -8,7 +8,7 @@ local utils = import 'mixin-utils/utils.libsonnet';
local cfg = self,
showMultiCluster:: true,
clusterLabel:: 'cluster',
clusterLabel:: $._config.per_cluster_label,
clusterMatchers::
if cfg.showMultiCluster then
[utils.selector.re(cfg.clusterLabel, '$cluster')]

Loading…
Cancel
Save