Skip to content

Commit

Permalink
fix(mixins): make bloom dashboards work with ssd
Browse files Browse the repository at this point in the history
  • Loading branch information
QuentinBisson committed Jul 24, 2024
1 parent 7aa7c15 commit d20aec0
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
"uid": "${datasource}"
},
"editorMode": "code",
"expr": "sum(rate(loki_bloom_gateway_filtered_chunks_sum{job=\"$namespace/bloom-gateway\"}[$__rate_interval]))\n/\nsum(rate(loki_bloom_gateway_requested_chunks_sum{job=\"$namespace/bloom-gateway\"}[$__rate_interval]))",
"expr": "sum(rate(loki_bloom_gateway_filtered_chunks_sum{job=~\"($namespace)/(loki.*|enterprise-logs)-backend\"}[$__rate_interval]))\n/\nsum(rate(loki_bloom_gateway_requested_chunks_sum{job=~\"($namespace)/(loki.*|enterprise-logs)-backend\"}[$__rate_interval]))",
"instant": false,
"legendFormat": "Chunks",
"range": true,
Expand All @@ -153,7 +153,7 @@
},
"editorMode": "code",
"exemplar": false,
"expr": "sum(rate(loki_bloom_gateway_filtered_series_sum{job=\"$namespace/bloom-gateway\"}[$__rate_interval]))\n/\nsum(rate(loki_bloom_gateway_requested_series_sum{job=\"$namespace/bloom-gateway\"}[$__rate_interval]))",
"expr": "sum(rate(loki_bloom_gateway_filtered_series_sum{job=~\"($namespace)/(loki.*|enterprise-logs)-backend\"}[$__rate_interval]))\n/\nsum(rate(loki_bloom_gateway_requested_series_sum{job=~\"($namespace)/(loki.*|enterprise-logs)-backend\"}[$__rate_interval]))",
"hide": false,
"instant": false,
"legendFormat": "Series",
Expand Down Expand Up @@ -235,7 +235,7 @@
},
"editorMode": "code",
"exemplar": false,
"expr": "sum(rate(loki_bloom_gateway_filtered_chunks_sum{job=\"$namespace/bloom-gateway\"}[$__rate_interval]))\n/\nsum(rate(loki_bloom_gateway_requested_chunks_sum{job=\"$namespace/bloom-gateway\"}[$__rate_interval]))",
"expr": "sum(rate(loki_bloom_gateway_filtered_chunks_sum{job=~\"($namespace)/(loki.*|enterprise-logs)-backend\"}[$__rate_interval]))\n/\nsum(rate(loki_bloom_gateway_requested_chunks_sum{job=~\"($namespace)/(loki.*|enterprise-logs)-backend\"}[$__rate_interval]))",
"instant": true,
"legendFormat": "Chunks",
"range": false,
Expand All @@ -248,7 +248,7 @@
},
"editorMode": "code",
"exemplar": false,
"expr": "sum(rate(loki_bloom_gateway_filtered_series_sum{job=\"$namespace/bloom-gateway\"}[$__rate_interval]))\n/\nsum(rate(loki_bloom_gateway_requested_series_sum{job=\"$namespace/bloom-gateway\"}[$__rate_interval]))",
"expr": "sum(rate(loki_bloom_gateway_filtered_series_sum{job=~\"($namespace)/(loki.*|enterprise-logs)-backend\"}[$__rate_interval]))\n/\nsum(rate(loki_bloom_gateway_requested_series_sum{job=~\"($namespace)/(loki.*|enterprise-logs)-backend\"}[$__rate_interval]))",
"hide": false,
"instant": true,
"legendFormat": "Series",
Expand All @@ -262,7 +262,7 @@
},
"editorMode": "code",
"exemplar": false,
"expr": "sum(loki_bloom_gateway_filtered_chunks_sum{job=\"$namespace/bloom-gateway\"})\n/\nsum(loki_bloom_gateway_requested_chunks_sum{job=\"$namespace/bloom-gateway\"})",
"expr": "sum(loki_bloom_gateway_filtered_chunks_sum{job=~\"($namespace)/(loki.*|enterprise-logs)-backend\"})\n/\nsum(loki_bloom_gateway_requested_chunks_sum{job=~\"($namespace)/(loki.*|enterprise-logs)-backend\"})",
"hide": true,
"instant": true,
"legendFormat": "Chunks avg",
Expand All @@ -276,7 +276,7 @@
},
"editorMode": "code",
"exemplar": false,
"expr": "sum(loki_bloom_gateway_filtered_series_sum{job=\"$namespace/bloom-gateway\"})\n/\nsum(loki_bloom_gateway_requested_series_sum{job=\"$namespace/bloom-gateway\"})",
"expr": "sum(loki_bloom_gateway_filtered_series_sum{job=~\"($namespace)/(loki.*|enterprise-logs)-backend\"})\n/\nsum(loki_bloom_gateway_requested_series_sum{job=~\"($namespace)/(loki.*|enterprise-logs)-backend\"})",
"hide": true,
"instant": true,
"legendFormat": "Series avg",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
"uid": "${datasource}"
},
"editorMode": "code",
"expr": "sum(rate(loki_bloom_gateway_filtered_chunks_sum{job=\"$namespace/bloom-gateway\"}[$__rate_interval]))\n/\nsum(rate(loki_bloom_gateway_requested_chunks_sum{job=\"$namespace/bloom-gateway\"}[$__rate_interval]))",
"expr": "sum(rate(loki_bloom_gateway_filtered_chunks_sum{job=~\"($namespace)/bloom-gateway\"}[$__rate_interval]))\n/\nsum(rate(loki_bloom_gateway_requested_chunks_sum{job=~\"($namespace)/bloom-gateway\"}[$__rate_interval]))",
"instant": false,
"legendFormat": "Chunks",
"range": true,
Expand All @@ -153,7 +153,7 @@
},
"editorMode": "code",
"exemplar": false,
"expr": "sum(rate(loki_bloom_gateway_filtered_series_sum{job=\"$namespace/bloom-gateway\"}[$__rate_interval]))\n/\nsum(rate(loki_bloom_gateway_requested_series_sum{job=\"$namespace/bloom-gateway\"}[$__rate_interval]))",
"expr": "sum(rate(loki_bloom_gateway_filtered_series_sum{job=~\"($namespace)/bloom-gateway\"}[$__rate_interval]))\n/\nsum(rate(loki_bloom_gateway_requested_series_sum{job=~\"($namespace)/bloom-gateway\"}[$__rate_interval]))",
"hide": false,
"instant": false,
"legendFormat": "Series",
Expand Down Expand Up @@ -235,7 +235,7 @@
},
"editorMode": "code",
"exemplar": false,
"expr": "sum(rate(loki_bloom_gateway_filtered_chunks_sum{job=\"$namespace/bloom-gateway\"}[$__rate_interval]))\n/\nsum(rate(loki_bloom_gateway_requested_chunks_sum{job=\"$namespace/bloom-gateway\"}[$__rate_interval]))",
"expr": "sum(rate(loki_bloom_gateway_filtered_chunks_sum{job=~\"($namespace)/bloom-gateway\"}[$__rate_interval]))\n/\nsum(rate(loki_bloom_gateway_requested_chunks_sum{job=~\"($namespace)/bloom-gateway\"}[$__rate_interval]))",
"instant": true,
"legendFormat": "Chunks",
"range": false,
Expand All @@ -248,7 +248,7 @@
},
"editorMode": "code",
"exemplar": false,
"expr": "sum(rate(loki_bloom_gateway_filtered_series_sum{job=\"$namespace/bloom-gateway\"}[$__rate_interval]))\n/\nsum(rate(loki_bloom_gateway_requested_series_sum{job=\"$namespace/bloom-gateway\"}[$__rate_interval]))",
"expr": "sum(rate(loki_bloom_gateway_filtered_series_sum{job=~\"($namespace)/bloom-gateway\"}[$__rate_interval]))\n/\nsum(rate(loki_bloom_gateway_requested_series_sum{job=~\"($namespace)/bloom-gateway\"}[$__rate_interval]))",
"hide": false,
"instant": true,
"legendFormat": "Series",
Expand All @@ -262,7 +262,7 @@
},
"editorMode": "code",
"exemplar": false,
"expr": "sum(loki_bloom_gateway_filtered_chunks_sum{job=\"$namespace/bloom-gateway\"})\n/\nsum(loki_bloom_gateway_requested_chunks_sum{job=\"$namespace/bloom-gateway\"})",
"expr": "sum(loki_bloom_gateway_filtered_chunks_sum{job=~\"($namespace)/bloom-gateway\"})\n/\nsum(loki_bloom_gateway_requested_chunks_sum{job=~\"($namespace)/bloom-gateway\"})",
"hide": true,
"instant": true,
"legendFormat": "Chunks avg",
Expand All @@ -276,7 +276,7 @@
},
"editorMode": "code",
"exemplar": false,
"expr": "sum(loki_bloom_gateway_filtered_series_sum{job=\"$namespace/bloom-gateway\"})\n/\nsum(loki_bloom_gateway_requested_series_sum{job=\"$namespace/bloom-gateway\"})",
"expr": "sum(loki_bloom_gateway_filtered_series_sum{job=~\"($namespace)/bloom-gateway\"})\n/\nsum(loki_bloom_gateway_requested_series_sum{job=~\"($namespace)/bloom-gateway\"})",
"hide": true,
"instant": true,
"legendFormat": "Series avg",
Expand Down
44 changes: 41 additions & 3 deletions production/loki-mixin/dashboards/loki-bloom-compactor.libsonnet
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
local raw = (import './dashboard-bloom-compactor.json');
local utils = import 'mixin-utils/utils.libsonnet';

// !--- HOW TO UPDATE THIS DASHBOARD ---!
// 1. Export the dashboard from Grafana as JSON
// !NOTE: Make sure you collapse all rows but the (first) Overview row.
// 2. Copy the JSON into `dashboard-bloom-compactor.json`
// 3. Delete the `id` and `templating` fields from the JSON
(import 'dashboard-utils.libsonnet') {
local bloom_compactor_job_matcher = if $._config.meta_monitoring.enabled
then [utils.selector.re('job', '($namespace)/(bloom-compactor|%s-backend|loki-single-binary)' % $._config.ssd.pod_prefix_matcher)]
else [utils.selector.re('job', '($namespace)/%s' % (if $._config.ssd.enabled then '%s-backend' % $._config.ssd.pod_prefix_matcher else 'bloom-compactor'))],
local bloom_compactor_pod_matcher = if $._config.meta_monitoring.enabled
then [utils.selector.re('pod', '(bloom-compactor|%s-backend|loki-single-binary)' % $._config.ssd.pod_prefix_matcher)]
else [utils.selector.re('pod', '%s' % (if $._config.ssd.enabled then '%s-backend.*' % $._config.ssd.pod_prefix_matcher else 'bloom-compactor.*'))],

grafanaDashboards+:
{
'loki-bloom-compactor.json':
Expand All @@ -29,27 +37,57 @@ local raw = (import './dashboard-bloom-compactor.json');
$._config.per_cluster_label + '_job'
),

local matcherStr(matcherId, matcher='job', sep=',') =
if matcher == 'job' then
if std.length(bloom_compactor_job_matcher) > 0 then
std.join(',', ['%(label)s%(op)s"%(value)s"' % matcher for matcher in bloom_compactor_job_matcher]) + sep
else error 'no job matchers'
else if matcher == 'pod' then
if std.length(bloom_compactor_pod_matcher) > 0 then
std.join(',', ['%(label)s%(op)s"%(value)s"' % matcher for matcher in bloom_compactor_pod_matcher]) + sep
else error 'no pod matchers'
else error 'matcher must be either job or container',

local replaceMatchers(expr) =
std.strReplace(
std.strReplace(
std.strReplace(
std.strReplace(
expr,
'pod=~"bloom-compactor.*"',
matcherStr('bloom-compactor', matcher='pod', sep='')
),
'job="$namespace/bloom-compactor",',
matcherStr('bloom-compactor')
),
'job="$namespace/bloom-compactor"',
std.rstripChars(matcherStr('bloom-compactor'), ',')
),
'job="($namespace)/bloom-compactor"',
std.rstripChars(matcherStr('bloom-compactor'), ',')
),

panels: [
p {
targets: if std.objectHas(p, 'targets') then [
e {
expr: replaceClusterMatchers(e.expr),
expr: replaceMatchers(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),
expr: replaceMatchers(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),
expr: replaceMatchers(replaceClusterMatchers(sspe.expr)),
}
for sspe in ssp.targets
] else [],
Expand Down
45 changes: 42 additions & 3 deletions production/loki-mixin/dashboards/loki-bloom-gateway.libsonnet
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
local raw = (import './dashboard-bloom-gateway.json');
local utils = import 'mixin-utils/utils.libsonnet';

// !--- HOW TO UPDATE THIS DASHBOARD ---!
// 1. Export the dashboard from Grafana as JSON
// !NOTE: Make sure you collapse all rows but the (first) Overview row.
// 2. Copy the JSON into `dashboard-bloom-gateway.json`
// 3. Delete the `id` and `templating` fields from the JSON
(import 'dashboard-utils.libsonnet') {
local bloom_gateway_job_matcher = if $._config.meta_monitoring.enabled
then [utils.selector.re('job', '($namespace)/(bloom-gateway|%s-backend|loki-single-binary)' % $._config.ssd.pod_prefix_matcher)]
else [utils.selector.re('job', '($namespace)/%s' % (if $._config.ssd.enabled then '%s-backend' % $._config.ssd.pod_prefix_matcher else 'bloom-gateway'))],
local bloom_gateway_pod_matcher = if $._config.meta_monitoring.enabled
then [utils.selector.re('pod', '(bloom-gateway|%s-backend|loki-single-binary)' % $._config.ssd.pod_prefix_matcher)]
else [utils.selector.re('pod', '%s' % (if $._config.ssd.enabled then '%s-backend.*' % $._config.ssd.pod_prefix_matcher else 'bloom-gateway.*'))],

grafanaDashboards+:
{
local dashboards = self,
'loki-bloom-gateway.json':
raw
{
Expand All @@ -29,27 +38,57 @@ local raw = (import './dashboard-bloom-gateway.json');
$._config.per_cluster_label + '_job'
),

local matcherStr(matcherId, matcher='job', sep=',') =
if matcher == 'job' then
if std.length(bloom_gateway_job_matcher) > 0 then
std.join(',', ['%(label)s%(op)s"%(value)s"' % matcher for matcher in bloom_gateway_job_matcher]) + sep
else error 'no job matchers'
else if matcher == 'pod' then
if std.length(bloom_gateway_pod_matcher) > 0 then
std.join(',', ['%(label)s%(op)s"%(value)s"' % matcher for matcher in bloom_gateway_pod_matcher]) + sep
else error 'no pod matchers'
else error 'matcher must be either job or container',

local replaceMatchers(expr) =
std.strReplace(
std.strReplace(
std.strReplace(
std.strReplace(
expr,
'pod=~"bloom-gateway.*"',
matcherStr('bloom-gateway', matcher='pod', sep='')
),
'job="$namespace/bloom-gateway",',
matcherStr('bloom-gateway')
),
'job="$namespace/bloom-gateway"',
std.rstripChars(matcherStr('bloom-gateway'), ',')
),
'job="($namespace)/bloom-gateway"',
std.rstripChars(matcherStr('bloom-gateway'), ',')
),

panels: [
p {
targets: if std.objectHas(p, 'targets') then [
e {
expr: replaceClusterMatchers(e.expr),
expr: replaceMatchers(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),
expr: replaceMatchers(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),
expr: replaceMatchers(replaceClusterMatchers(sspe.expr)),
}
for sspe in ssp.targets
] else [],
Expand Down

0 comments on commit d20aec0

Please sign in to comment.