Skip to content

Commit

Permalink
Revert "loki-mixin: use centralized configuration for dashboard match…
Browse files Browse the repository at this point in the history
…ers / selectors (#4279)" (#4441)

This reverts commit 1a4be09.
  • Loading branch information
owen-d committed Oct 8, 2021
1 parent 1b0e3f8 commit cf5f690
Show file tree
Hide file tree
Showing 11 changed files with 538 additions and 313 deletions.
15 changes: 0 additions & 15 deletions production/loki-mixin/config.libsonnet
Expand Up @@ -3,25 +3,10 @@
// Tags for dashboards.
tags: ['loki'],

singleBinary: false,

// The label used to differentiate between different application instances (i.e. 'pod' in a kubernetes install).
per_instance_label: 'pod',

// The label used to differentiate between different nodes (i.e. servers).
per_node_label: 'instance',

// These are used by the dashboards and allow for the simultaneous display of
// microservice and single binary loki clusters.
job_names: {
gateway: '(gateway|loki-gw|loki-gw-internal)',
query_frontend: '(query-frontend.*|loki$)', // Match also custom query-frontend deployments.
querier: '(querier.*|loki$)', // Match also custom querier deployments.
ingester: '(ingester.*|loki$)', // Match also custom and per-zone ingester deployments.
distributor: '(distributor.*|loki$)',
index_gateway: '(index-gateway.*|querier.*|loki$)',
ruler: '(ruler|loki$)',
compactor: 'compactor.*', // Match also custom compactor deployments.
},
},
}
10 changes: 2 additions & 8 deletions production/loki-mixin/dashboards/dashboard-utils.libsonnet
Expand Up @@ -47,20 +47,15 @@ local utils = import 'mixin-utils/utils.libsonnet';
d.addMultiTemplate('cluster', 'loki_build_info', 'cluster')
.addMultiTemplate('namespace', 'loki_build_info', 'namespace')
else
d.addMultiTemplate('cluster', 'loki_build_info', 'cluster'),
d.addTemplate('cluster', 'loki_build_info', 'cluster')
.addTemplate('namespace', 'loki_build_info', 'namespace'),
},

jobSelector(job)::
if $._config.singleBinary
then [utils.selector.noop('cluster'), utils.selector.re('job', '$job')]
else [utils.selector.re('cluster', '$cluster'), utils.selector.re('job', '($namespace)/%s' % job)],

jobMatcher(job)::
'cluster=~"$cluster", job=~"($namespace)/%s"' % job,

namespaceMatcher()::
'cluster=~"$cluster", namespace=~"$namespace"',

logPanel(title, selector, datasource='$logs'):: {
title: title,
type: 'logs',
Expand Down Expand Up @@ -121,7 +116,6 @@ local utils = import 'mixin-utils/utils.libsonnet';
},
datasource: '$datasource',
},

containerCPUUsagePanel(title, containerName)::
$.panel(title) +
$.queryPanel([
Expand Down
238 changes: 161 additions & 77 deletions production/loki-mixin/dashboards/loki-chunks.libsonnet
@@ -1,88 +1,172 @@
local utils = import 'mixin-utils/utils.libsonnet';

{
(import 'dashboard-utils.libsonnet') {
grafanaDashboards+: {
'loki-chunks.json':
($.dashboard('Loki / Chunks'))
.addClusterSelectorTemplates(false)
.addRow(
$.row('Active Series / Chunks')
.addPanel(
$.panel('Series') +
$.queryPanel('sum(loki_ingester_memory_chunks{%s})' % $.jobMatcher($._config.job_names.ingester), 'series'),
)
.addPanel(
$.panel('Chunks per series') +
$.queryPanel(
'sum(loki_ingester_memory_chunks{%s}) / sum(loki_ingester_memory_streams{job=~"%s"})' % [
$.jobMatcher($._config.job_names.ingester),
$.jobMatcher($._config.job_names.ingester),
],
'chunks'
),
)
local dashboards = self,

'loki-chunks.json':{
local cfg = self,

showMultiCluster:: true,
clusterLabel:: 'cluster',
clusterMatchers::
if cfg.showMultiCluster then
[utils.selector.re(cfg.clusterLabel, '$cluster')]
else
[],

namespaceType:: 'query',
namespaceQuery::
if cfg.showMultiCluster then
'kube_pod_container_info{cluster="$cluster", image=~".*loki.*"}'
else
'kube_pod_container_info{image=~".*loki.*"}',

assert (cfg.namespaceType == 'custom' || cfg.namespaceType == 'query') : "Only types 'query' and 'custom' are allowed for dashboard variable 'namespace'",

matchers:: {
ingester: [utils.selector.re('job', '($namespace)/ingester')],
},

local selector(matcherId) =
std.join(',', ['%(label)s%(op)s"%(value)s"' % matcher for matcher in (cfg.clusterMatchers + cfg.matchers[matcherId])]),

ingesterSelector:: selector('ingester'),
ingesterSelectorOnly::
std.join(',', ['%(label)s%(op)s"%(value)s"' % matcher for matcher in cfg.matchers.ingester]),

templateLabels:: (
if cfg.showMultiCluster then [
{
variable:: 'cluster',
label:: cfg.clusterLabel,
query:: 'kube_pod_container_info{image=~".*loki.*"}',
type:: 'query'
},
] else []
) + [
{
variable:: 'namespace',
label:: 'namespace',
query:: cfg.namespaceQuery,
type:: cfg.namespaceType
},
],
} +
$.dashboard('Loki / Chunks')
.addClusterSelectorTemplates(false)
.addRow(
$.row('Active Series / Chunks')
.addPanel(
$.panel('Series') +
$.queryPanel('sum(loki_ingester_memory_chunks{%s})' % dashboards['loki-chunks.json'].ingesterSelector, 'series'),
)
.addRow(
$.row('Flush Stats')
.addPanel(
$.panel('Utilization') +
$.latencyPanel('loki_ingester_chunk_utilization', '{%s}' % $.jobMatcher($._config.job_names.ingester), multiplier='1') +
{ yaxes: $.yaxes('percentunit') },
)
.addPanel(
$.panel('Age') +
$.latencyPanel('loki_ingester_chunk_age_seconds', '{%s}' % $.jobMatcher($._config.job_names.ingester)),
.addPanel(
$.panel('Chunks per series') +
$.queryPanel(
'sum(loki_ingester_memory_chunks{%s}) / sum(loki_ingester_memory_streams{%s})' % [
dashboards['loki-chunks.json'].ingesterSelector,
dashboards['loki-chunks.json'].ingesterSelectorOnly,
],
'chunks'
),
)
.addRow(
$.row('Flush Stats')
.addPanel(
$.panel('Size') +
$.latencyPanel('loki_ingester_chunk_entries', '{%s}' % $.jobMatcher($._config.job_names.ingester), multiplier='1') +
{ yaxes: $.yaxes('short') },
)
.addPanel(
$.panel('Entries') +
$.queryPanel(
'sum(rate(loki_chunk_store_index_entries_per_chunk_sum{%s}[5m])) / sum(rate(loki_chunk_store_index_entries_per_chunk_count{%s}[5m]))' % [
$.jobMatcher($._config.job_names.ingester),
$.jobMatcher($._config.job_names.ingester),
],
'entries'
),
),
)
.addRow(
$.row('Flush Stats')
.addPanel(
$.panel('Utilization') +
$.latencyPanel('loki_ingester_chunk_utilization', '{%s}' % dashboards['loki-chunks.json'].ingesterSelector, multiplier='1') +
{ yaxes: $.yaxes('percentunit') },
)
.addPanel(
$.panel('Age') +
$.latencyPanel('loki_ingester_chunk_age_seconds', '{%s}' % dashboards['loki-chunks.json'].ingesterSelector),
),
)
.addRow(
$.row('Flush Stats')
.addPanel(
$.panel('Size') +
$.latencyPanel('loki_ingester_chunk_entries', '{%s}' % dashboards['loki-chunks.json'].ingesterSelector, multiplier='1') +
{ yaxes: $.yaxes('short') },
)
.addRow(
$.row('Flush Stats')
.addPanel(
$.panel('Queue Length') +
$.queryPanel('cortex_ingester_flush_queue_length{%s}' % $.jobMatcher($._config.job_names.ingester), '{{pod}}'),
)
.addPanel(
$.panel('Flush Rate') +
$.qpsPanel('loki_ingester_chunk_age_seconds_count{%s}' % $.jobMatcher($._config.job_names.ingester),),
.addPanel(
$.panel('Entries') +
$.queryPanel(
'sum(rate(loki_chunk_store_index_entries_per_chunk_sum{%s}[5m])) / sum(rate(loki_chunk_store_index_entries_per_chunk_count{%s}[5m]))' % [
dashboards['loki-chunks.json'].ingesterSelector,
dashboards['loki-chunks.json'].ingesterSelector,
],
'entries'
),
),
)
.addRow(
$.row('Flush Stats')
.addPanel(
$.panel('Queue Length') +
$.queryPanel('cortex_ingester_flush_queue_length{%s}' % dashboards['loki-chunks.json'].ingesterSelector, '{{pod}}'),
)
.addRow(
$.row('Duration')
.addPanel(
$.panel('Chunk Duration hours (end-start)') +
$.queryPanel(
[
'histogram_quantile(0.5, sum(rate(loki_ingester_chunk_bounds_hours_bucket{%s}[5m])) by (le))' % $.jobMatcher($._config.job_names.ingester),
'histogram_quantile(0.99, sum(rate(loki_ingester_chunk_bounds_hours_bucket{%s}[5m])) by (le))' % $.jobMatcher($._config.job_names.ingester),
'sum(rate(loki_ingester_chunk_bounds_hours_sum{%s}[5m])) / sum(rate(loki_ingester_chunk_bounds_hours_count{%s}[5m]))' % [
$.jobMatcher($._config.job_names.ingester),
$.jobMatcher($._config.job_names.ingester),
],
],
[
'p50',
'p99',
'avg',
],
),
)
.addPanel(
$.panel('Flush Rate') +
$.qpsPanel('loki_ingester_chunk_age_seconds_count{%s}' % dashboards['loki-chunks.json'].ingesterSelector,),
),
},
)
.addRow(
$.row('Duration')
.addPanel(
$.panel('Chunk Duration hours (end-start)') +
$.queryPanel(
[
'histogram_quantile(0.5, sum(rate(loki_ingester_chunk_bounds_hours_bucket{%s}[5m])) by (le))' % dashboards['loki-chunks.json'].ingesterSelector,
'histogram_quantile(0.99, sum(rate(loki_ingester_chunk_bounds_hours_bucket{%s}[5m])) by (le))' % dashboards['loki-chunks.json'].ingesterSelector,
'sum(rate(loki_ingester_chunk_bounds_hours_sum{%s}[5m])) / sum(rate(loki_ingester_chunk_bounds_hours_count{%s}[5m]))' % [
dashboards['loki-chunks.json'].ingesterSelector,
dashboards['loki-chunks.json'].ingesterSelector,
],
],
[
'p50',
'p99',
'avg',
],
),
)
){
templating+: {
list+: [
{
allValue: null,
current:
if l.type == 'custom' then {
text: l.query,
value: l.query,
} else {},
datasource: '$datasource',
hide: 0,
includeAll: false,
label: l.variable,
multi: false,
name: l.variable,
options: [],
query:
if l.type == 'query' then
'label_values(%s, %s)' % [l.query, l.label]
else
l.query,
refresh: 1,
regex: '',
sort: 2,
tagValuesQuery: '',
tags: [],
tagsQuery: '',
type: l.type,
useTags: false,
}
for l in dashboards['loki-chunks.json'].templateLabels
],
},
},
}
}
17 changes: 9 additions & 8 deletions production/loki-mixin/dashboards/loki-deletion.libsonnet
@@ -1,3 +1,4 @@
local g = import 'grafana-builder/grafana.libsonnet';
local utils = import 'mixin-utils/utils.libsonnet';

(import 'dashboard-utils.libsonnet') {
Expand All @@ -22,20 +23,20 @@ local utils = import 'mixin-utils/utils.libsonnet';
)
)
.addRow(
$.row('Churn')
g.row('Churn')
.addPanel(
$.panel('Delete Requests Received / Day') +
$.queryPanel('sum(increase(loki_compactor_delete_requests_received_total{%s}[1d]))' % $.namespaceMatcher(), 'received'),
g.panel('Delete Requests Received / Day') +
g.queryPanel('sum(increase(loki_compactor_delete_requests_received_total{%s}[1d]))' % $.namespaceMatcher(), 'received'),
)
.addPanel(
$.panel('Delete Requests Processed / Day') +
$.queryPanel('sum(increase(loki_compactor_delete_requests_processed_total{%s}[1d]))' % $.namespaceMatcher(), 'processed'),
g.panel('Delete Requests Processed / Day') +
g.queryPanel('sum(increase(loki_compactor_delete_requests_processed_total{%s}[1d]))' % $.namespaceMatcher(), 'processed'),
)
).addRow(
$.row('Failures')
g.row('Failures')
.addPanel(
$.panel('Failures in Loading Delete Requests / Hour') +
$.queryPanel('sum(increase(loki_compactor_load_pending_requests_attempts_total{status="fail", %s}[1h]))' % $.namespaceMatcher(), 'failures'),
g.panel('Failures in Loading Delete Requests / Hour') +
g.queryPanel('sum(increase(loki_compactor_load_pending_requests_attempts_total{status="fail", %s}[1h]))' % $.namespaceMatcher(), 'failures'),
)
),
},
Expand Down
12 changes: 6 additions & 6 deletions production/loki-mixin/dashboards/loki-reads-resources.libsonnet
Expand Up @@ -15,7 +15,7 @@ local utils = import 'mixin-utils/utils.libsonnet';
$.containerMemoryWorkingSetPanel('Memory (workingset)', 'cortex-gw'),
)
.addPanel(
$.goHeapInUsePanel('Memory (go heap inuse)', $._config.job_names.gateway),
$.goHeapInUsePanel('Memory (go heap inuse)', 'cortex-gw'),
)
)
.addRow(
Expand All @@ -27,7 +27,7 @@ local utils = import 'mixin-utils/utils.libsonnet';
$.containerMemoryWorkingSetPanel('Memory (workingset)', 'query-frontend'),
)
.addPanel(
$.goHeapInUsePanel('Memory (go heap inuse)', $._config.job_names.query_frontend),
$.goHeapInUsePanel('Memory (go heap inuse)', 'query-frontend'),
)
)
.addRow(
Expand All @@ -39,7 +39,7 @@ local utils = import 'mixin-utils/utils.libsonnet';
$.containerMemoryWorkingSetPanel('Memory (workingset)', 'querier'),
)
.addPanel(
$.goHeapInUsePanel('Memory (go heap inuse)', $._config.job_names.querier),
$.goHeapInUsePanel('Memory (go heap inuse)', 'querier'),
)
)
.addRow(
Expand Down Expand Up @@ -77,7 +77,7 @@ local utils = import 'mixin-utils/utils.libsonnet';
$.containerMemoryWorkingSetPanel('Memory (workingset)', 'index-gateway'),
)
.addPanel(
$.goHeapInUsePanel('Memory (go heap inuse)', $._config.job_names.index_gateway),
$.goHeapInUsePanel('Memory (go heap inuse)', 'index-gateway'),
)
)
.addRow(
Expand Down Expand Up @@ -115,7 +115,7 @@ local utils = import 'mixin-utils/utils.libsonnet';
$.containerMemoryWorkingSetPanel('Memory (workingset)', 'ingester'),
)
.addPanel(
$.goHeapInUsePanel('Memory (go heap inuse)', $._config.job_names.ingester),
$.goHeapInUsePanel('Memory (go heap inuse)', 'ingester'),
)
)
.addRow(
Expand All @@ -137,7 +137,7 @@ local utils = import 'mixin-utils/utils.libsonnet';
$.containerMemoryWorkingSetPanel('Memory (workingset)', 'ruler'),
)
.addPanel(
$.goHeapInUsePanel('Memory (go heap inuse)', $._config.job_names.ruler),
$.goHeapInUsePanel('Memory (go heap inuse)', 'ruler'),
)
),
},
Expand Down

0 comments on commit cf5f690

Please sign in to comment.