Skip to content

Commit

Permalink
Add tag/link fix to operational dashboard and promtail mixin dashboar…
Browse files Browse the repository at this point in the history
…d. (#4423)

Signed-off-by: Callum Styan <callumstyan@gmail.com>
  • Loading branch information
cstyan authored Oct 7, 2021
1 parent 69d81df commit c820103
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
24 changes: 20 additions & 4 deletions production/loki-mixin/dashboards/loki-operational.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ local utils = import 'mixin-utils/utils.libsonnet';
query:: 'loki',
},
{
name:: 'metrics',
name:: 'datasource',
type:: 'datasource',
query:: 'prometheus',
},
Expand All @@ -46,7 +46,7 @@ local utils = import 'mixin-utils/utils.libsonnet';
variable:: 'cluster',
label:: cfg.clusterLabel,
query:: 'kube_pod_container_info{image=~".*loki.*", container!="loki-canary"}',
datasource:: '$metrics',
datasource:: '$datasource',
type:: 'query',
},
] else []
Expand All @@ -55,7 +55,7 @@ local utils = import 'mixin-utils/utils.libsonnet';
variable:: 'namespace',
label:: 'namespace',
query:: cfg.namespaceQuery,
datasource:: '$metrics',
datasource:: '$datasource',
type:: cfg.namespaceType,
},
],
Expand Down Expand Up @@ -149,7 +149,7 @@ local utils = import 'mixin-utils/utils.libsonnet';

local selectDatasource(ds) =
if ds == null || ds == '' then ds
else if ds == '$datasource' then '$metrics'
else if ds == '$datasource' then '$datasource'
else '$logs',

panels: [
Expand Down Expand Up @@ -238,6 +238,22 @@ local utils = import 'mixin-utils/utils.libsonnet';
if l.type == 'query' || l.type == 'custom'
],
},
} + {
// ugly hack, copy pasta the tag/link
// code from the loki-mixin
tags: ['loki'],
links+: [
{
asDropdown: true,
icon: 'external link',
includeVars: true,
keepTime: true,
tags: $._config.tags,
targetBlank: false,
title: 'Loki Dashboards',
type: 'dashboards',
},
],
},
},
}
20 changes: 10 additions & 10 deletions production/promtail-mixin/dashboards.libsonnet
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
local g = import 'grafana-builder/grafana.libsonnet';
local utils = import 'mixin-utils/utils.libsonnet';
local loki_mixin_utils = import 'loki-mixin/dashboards/dashboard-utils.libsonnet';

{
grafanaDashboards+: {
local dashboard = (
loki_mixin_utils {
_config+:: { tags: ['loki'] },
}
),
local dashboards = self,

'promtail.json':{
Expand All @@ -16,14 +22,7 @@ local utils = import 'mixin-utils/utils.libsonnet';
selector:: std.join(',', ['%(label)s%(op)s"%(value)s"' % matcher for matcher in (cfg.clusterMatchers + dashboards['promtail.json'].matchers)]),

templateLabels:: (
if cfg.showMultiCluster then [
{
variable:: 'cluster',
label:: cfg.clusterLabel,
query:: 'kube_pod_container_info{image=~".*promtail.*"}',
},
] else []
) + [
[
{
variable:: 'namespace',
label:: 'namespace',
Expand All @@ -34,9 +33,10 @@ local utils = import 'mixin-utils/utils.libsonnet';
label:: 'created_by_name',
query:: 'kube_pod_info{namespace="$namespace",pod=~"promtail.*"}',
},
],
]),
} +
g.dashboard('Loki / Promtail')
dashboard.dashboard('Loki / Promtail')
.addClusterSelectorTemplates(false)
.addRow(
g.row('Targets & Files')
.addPanel(
Expand Down

0 comments on commit c820103

Please sign in to comment.