From c820103581b4c83d389efadeb0652a3368f61622 Mon Sep 17 00:00:00 2001 From: Callum Styan Date: Wed, 6 Oct 2021 17:25:55 -0700 Subject: [PATCH] Add tag/link fix to operational dashboard and promtail mixin dashboard. (#4423) Signed-off-by: Callum Styan --- .../dashboards/loki-operational.libsonnet | 24 +++++++++++++++---- .../promtail-mixin/dashboards.libsonnet | 20 ++++++++-------- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/production/loki-mixin/dashboards/loki-operational.libsonnet b/production/loki-mixin/dashboards/loki-operational.libsonnet index d8e0faa4082aa..336f9b8230aeb 100644 --- a/production/loki-mixin/dashboards/loki-operational.libsonnet +++ b/production/loki-mixin/dashboards/loki-operational.libsonnet @@ -36,7 +36,7 @@ local utils = import 'mixin-utils/utils.libsonnet'; query:: 'loki', }, { - name:: 'metrics', + name:: 'datasource', type:: 'datasource', query:: 'prometheus', }, @@ -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 [] @@ -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, }, ], @@ -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: [ @@ -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', + }, + ], }, }, } diff --git a/production/promtail-mixin/dashboards.libsonnet b/production/promtail-mixin/dashboards.libsonnet index 461b78f4997f2..781625b80944c 100644 --- a/production/promtail-mixin/dashboards.libsonnet +++ b/production/promtail-mixin/dashboards.libsonnet @@ -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':{ @@ -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', @@ -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(