Skip to content

Commit

Permalink
feat: mixins / allow bloom dashboards disabling (#14177)
Browse files Browse the repository at this point in the history
This PR allows hiding the bloom dashboards if they are not used.
  • Loading branch information
QuentinBisson authored Sep 19, 2024
1 parent a26416d commit ce2e6d5
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 116 deletions.
5 changes: 5 additions & 0 deletions production/loki-mixin/config.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
// Enable dashboard and panels for Grafana Labs internal components.
internal_components: false,

blooms: {
// Whether or not to include blooms specific dashboards
enabled: true,
},

promtail: {
// Whether or not to include promtail specific dashboards
enabled: true,
Expand Down
115 changes: 57 additions & 58 deletions production/loki-mixin/dashboards/loki-bloom-compactor.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -6,67 +6,66 @@ local raw = (import './dashboard-bloom-compactor.json');
// 2. Copy the JSON into `dashboard-bloom-compactor.json`
// 3. Delete the `id` and `templating` fields from the JSON
(import 'dashboard-utils.libsonnet') {
grafanaDashboards+:
{
'loki-bloom-compactor.json':
raw
{
local replaceClusterMatchers(expr) =
// Replace the recording rules cluster label with the per-cluster label
grafanaDashboards+:: if !$._config.blooms.enabled then {} else {
'loki-bloom-compactor.json':
raw
{
local replaceClusterMatchers(expr) =
// Replace the recording rules cluster label with the per-cluster label
std.strReplace(
// Replace the cluster label for equality matchers with the per-cluster label
std.strReplace(
// Replace the cluster label for equality matchers with the per-cluster label
// Replace the cluster label for regex matchers with the per-cluster label
std.strReplace(
// Replace the cluster label for regex matchers with the per-cluster label
std.strReplace(
expr,
'cluster=~"$cluster"',
$._config.per_cluster_label + '=~"$cluster"'
),
'cluster="$cluster"',
$._config.per_cluster_label + '="$cluster"'
expr,
'cluster=~"$cluster"',
$._config.per_cluster_label + '=~"$cluster"'
),
'cluster_job',
$._config.per_cluster_label + '_job'
'cluster="$cluster"',
$._config.per_cluster_label + '="$cluster"'
),
'cluster_job',
$._config.per_cluster_label + '_job'
),

panels: [
p {
targets: if std.objectHas(p, 'targets') then [
e {
expr: replaceClusterMatchers(e.expr),
}
for e in p.targets
] else [],
panels: if std.objectHas(p, 'panels') then [
sp {
targets: if std.objectHas(sp, 'targets') then [
spe {
expr: replaceClusterMatchers(spe.expr),
}
for spe in sp.targets
] else [],
panels: if std.objectHas(sp, 'panels') then [
ssp {
targets: if std.objectHas(ssp, 'targets') then [
sspe {
expr: replaceClusterMatchers(sspe.expr),
}
for sspe in ssp.targets
] else [],
}
for ssp in sp.panels
] else [],
}
for sp in p.panels
] else [],
}
for p in super.panels
],
}
+ $.dashboard('Loki / Bloom Compactor', uid='bloom-compactor')
.addCluster()
.addNamespace()
.addLog()
.addTag(),
},
panels: [
p {
targets: if std.objectHas(p, 'targets') then [
e {
expr: replaceClusterMatchers(e.expr),
}
for e in p.targets
] else [],
panels: if std.objectHas(p, 'panels') then [
sp {
targets: if std.objectHas(sp, 'targets') then [
spe {
expr: replaceClusterMatchers(spe.expr),
}
for spe in sp.targets
] else [],
panels: if std.objectHas(sp, 'panels') then [
ssp {
targets: if std.objectHas(ssp, 'targets') then [
sspe {
expr: replaceClusterMatchers(sspe.expr),
}
for sspe in ssp.targets
] else [],
}
for ssp in sp.panels
] else [],
}
for sp in p.panels
] else [],
}
for p in super.panels
],
}
+ $.dashboard('Loki / Bloom Compactor', uid='bloom-compactor')
.addCluster()
.addNamespace()
.addLog()
.addTag(),
},
}
115 changes: 57 additions & 58 deletions production/loki-mixin/dashboards/loki-bloom-gateway.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -6,67 +6,66 @@ local raw = (import './dashboard-bloom-gateway.json');
// 2. Copy the JSON into `dashboard-bloom-gateway.json`
// 3. Delete the `id` and `templating` fields from the JSON
(import 'dashboard-utils.libsonnet') {
grafanaDashboards+:
{
'loki-bloom-gateway.json':
raw
{
local replaceClusterMatchers(expr) =
// Replace the recording rules cluster label with the per-cluster label
grafanaDashboards+:: if !$._config.blooms.enabled then {} else {
'loki-bloom-gateway.json':
raw
{
local replaceClusterMatchers(expr) =
// Replace the recording rules cluster label with the per-cluster label
std.strReplace(
// Replace the cluster label for equality matchers with the per-cluster label
std.strReplace(
// Replace the cluster label for equality matchers with the per-cluster label
// Replace the cluster label for regex matchers with the per-cluster label
std.strReplace(
// Replace the cluster label for regex matchers with the per-cluster label
std.strReplace(
expr,
'cluster=~"$cluster"',
$._config.per_cluster_label + '=~"$cluster"'
),
'cluster="$cluster"',
$._config.per_cluster_label + '="$cluster"'
expr,
'cluster=~"$cluster"',
$._config.per_cluster_label + '=~"$cluster"'
),
'cluster_job',
$._config.per_cluster_label + '_job'
'cluster="$cluster"',
$._config.per_cluster_label + '="$cluster"'
),
'cluster_job',
$._config.per_cluster_label + '_job'
),

panels: [
p {
targets: if std.objectHas(p, 'targets') then [
e {
expr: replaceClusterMatchers(e.expr),
}
for e in p.targets
] else [],
panels: if std.objectHas(p, 'panels') then [
sp {
targets: if std.objectHas(sp, 'targets') then [
spe {
expr: replaceClusterMatchers(spe.expr),
}
for spe in sp.targets
] else [],
panels: if std.objectHas(sp, 'panels') then [
ssp {
targets: if std.objectHas(ssp, 'targets') then [
sspe {
expr: replaceClusterMatchers(sspe.expr),
}
for sspe in ssp.targets
] else [],
}
for ssp in sp.panels
] else [],
}
for sp in p.panels
] else [],
}
for p in super.panels
],
}
+ $.dashboard('Loki / Bloom Gateway', uid='bloom-gateway')
.addCluster()
.addNamespace()
.addLog()
.addTag(),
},
panels: [
p {
targets: if std.objectHas(p, 'targets') then [
e {
expr: replaceClusterMatchers(e.expr),
}
for e in p.targets
] else [],
panels: if std.objectHas(p, 'panels') then [
sp {
targets: if std.objectHas(sp, 'targets') then [
spe {
expr: replaceClusterMatchers(spe.expr),
}
for spe in sp.targets
] else [],
panels: if std.objectHas(sp, 'panels') then [
ssp {
targets: if std.objectHas(ssp, 'targets') then [
sspe {
expr: replaceClusterMatchers(sspe.expr),
}
for sspe in ssp.targets
] else [],
}
for ssp in sp.panels
] else [],
}
for sp in p.panels
] else [],
}
for p in super.panels
],
}
+ $.dashboard('Loki / Bloom Gateway', uid='bloom-gateway')
.addCluster()
.addNamespace()
.addLog()
.addTag(),
},
}

0 comments on commit ce2e6d5

Please sign in to comment.