Skip to content

Commit 488c847

Browse files
committed
modernize the redis-enterprise mixin to use modern libraries
1 parent 38e888e commit 488c847

23 files changed

+3940
-7547
lines changed

redis-enterprise-mixin/alerts/alerts.libsonnet renamed to redis-enterprise-mixin/alerts.libsonnet

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
2-
prometheusAlerts+:: {
3-
groups+: [
2+
new(this): {
3+
groups: [
44
{
55
name: 'RedisEnterpriseAlerts',
66
rules: [
77
{
88
alert: 'RedisEnterpriseClusterOutOfMemory',
99
expr: |||
10-
sum(redis_used_memory) by (redis_cluster, node) / sum(node_available_memory) by (redis_cluster, node) * 100 > %(alertsClusterOutOfMemoryThreshold)s
11-
||| % $._config,
10+
sum(redis_used_memory{%(filteringSelector)s}) by (redis_cluster, node) / sum(node_available_memory{%(filteringSelector)s}) by (redis_cluster, node) * 100 > %(alertsClusterOutOfMemoryThreshold)s
11+
||| % this.config,
1212
'for': '5m',
1313
labels: {
1414
severity: 'critical',
@@ -19,14 +19,14 @@
1919
(
2020
'Memory usage is at {{ printf "%%.0f" $value }} percent on the cluster {{$labels.redis_cluster}}, ' +
2121
"which is above the configured threshold of %(alertsClusterOutOfMemoryThreshold)s%% of the cluster's available memory"
22-
) % $._config,
22+
) % this.config,
2323
},
2424
},
2525
{
2626
alert: 'RedisEnterpriseNodeNotResponding',
2727
expr: |||
28-
node_up == 0
29-
||| % $._config,
28+
node_up{%(filteringSelector)s} == 0
29+
||| % this.config,
3030
'for': '5m',
3131
labels: {
3232
severity: 'critical',
@@ -36,14 +36,14 @@
3636
description:
3737
(
3838
'The node {{$labels.node}} in {{$labels.redis_cluster}} is offline or unreachable.'
39-
) % $._config,
39+
) % this.config,
4040
},
4141
},
4242
{
4343
alert: 'RedisEnterpriseDatabaseNotResponding',
4444
expr: |||
45-
bdb_up == 0
46-
||| % $._config,
45+
bdb_up{%(filteringSelector)s} == 0
46+
||| % this.config,
4747
'for': '5m',
4848
labels: {
4949
severity: 'critical',
@@ -53,14 +53,14 @@
5353
description:
5454
(
5555
'The database {{$labels.bdb}} in {{$labels.redis_cluster}} is offline or unreachable.'
56-
) % $._config,
56+
) % this.config,
5757
},
5858
},
5959
{
6060
alert: 'RedisEnterpriseShardNotResponding',
6161
expr: |||
62-
redis_up == 0
63-
||| % $._config,
62+
redis_up{%(filteringSelector)s} == 0
63+
||| % this.config,
6464
'for': '5m',
6565
labels: {
6666
severity: 'critical',
@@ -70,14 +70,14 @@
7070
description:
7171
(
7272
'The shard {{$labels.redis}} on database {{$labels.bdb}} running on node {{$labels.node}} in the cluster {{$labels.redis_cluster}} is offline or unreachable.'
73-
) % $._config,
73+
) % this.config,
7474
},
7575
},
7676
{
7777
alert: 'RedisEnterpriseNodeHighCPUUtilization',
7878
expr: |||
79-
(sum(node_cpu_user) by (node, redis_cluster, job) + sum(node_cpu_system) by (node, redis_cluster, job)) * 100 > %(alertsNodeCPUHighUtilizationThreshold)s
80-
||| % $._config,
79+
(sum(node_cpu_user{%(filteringSelector)s}) by (node, redis_cluster, job) + sum(node_cpu_system{%(filteringSelector)s}) by (node, redis_cluster, job)) * 100 > %(alertsNodeCPUHighUtilizationThreshold)s
80+
||| % this.config,
8181
'for': '5m',
8282
labels: {
8383
severity: 'warning',
@@ -88,14 +88,14 @@
8888
(
8989
'The node {{$labels.node}} in cluster {{$labels.redis_cluster}} has a CPU percentage of ${{ printf "%%.0f" $value }}, which exceeds ' +
9090
'the threshold %(alertsNodeCPUHighUtilizationThreshold)s%%.'
91-
) % $._config,
91+
) % this.config,
9292
},
9393
},
9494
{
9595
alert: 'RedisEnterpriseDatabaseHighMemoryUtilization',
9696
expr: |||
97-
sum(bdb_used_memory) by (bdb, redis_cluster) / sum(bdb_memory_limit) by (bdb, redis_cluster) * 100 > %(alertsDatabaseHighMemoryUtiliation)s
98-
||| % $._config,
97+
sum(bdb_used_memory{%(filteringSelector)s}) by (bdb, redis_cluster) / sum(bdb_memory_limit{%(filteringSelector)s}) by (bdb, redis_cluster) * 100 > %(alertsDatabaseHighMemoryUtilization)s
98+
||| % this.config,
9999
'for': '5m',
100100
labels: {
101101
severity: 'warning',
@@ -104,16 +104,16 @@
104104
summary: 'Node memory utilization is above the configured threshold.',
105105
description:
106106
(
107-
'The database {{$labels.bdb}} in cluster {{$labels.redis_cluster}} has a memory utiliztaion of ${{ printf "%%.0f" $value }}, which exceeds ' +
108-
'the threshold %(alertsDatabaseHighMemoryUtiliation)s%%.'
109-
) % $._config,
107+
'The database {{$labels.bdb}} in cluster {{$labels.redis_cluster}} has a memory utilization of ${{ printf "%%.0f" $value }}, which exceeds ' +
108+
'the threshold %(alertsDatabaseHighMemoryUtilization)s%%.'
109+
) % this.config,
110110
},
111111
},
112112
{
113113
alert: 'RedisEnterpriseAverageLatencyIncreasing',
114114
expr: |||
115-
bdb_avg_latency / 1000 > %(alertsDatabaseHighLatencyMs)s
116-
||| % $._config,
115+
bdb_avg_latency{%(filteringSelector)s} / 1000 > %(alertsDatabaseHighLatencyMs)s
116+
||| % this.config,
117117
'for': '5m',
118118
labels: {
119119
severity: 'warning',
@@ -124,14 +124,14 @@
124124
(
125125
'The database {{$labels.bdb}} in cluster {{$labels.redis_cluster}} has high latency of ${{ printf "%%.0f" $value }}, which exceeds ' +
126126
'the threshold of %(alertsDatabaseHighLatencyMs)s ms.'
127-
) % $._config,
127+
) % this.config,
128128
},
129129
},
130130
{
131131
alert: 'RedisEnterpriseKeyEvictionsIncreasing',
132132
expr: |||
133-
bdb_evicted_objects >= %(alertsEvictedObjectsThreshold)s
134-
||| % $._config,
133+
bdb_evicted_objects{%(filteringSelector)s} >= %(alertsEvictedObjectsThreshold)s
134+
||| % this.config,
135135
'for': '5m',
136136
labels: {
137137
severity: 'warning',
@@ -142,7 +142,7 @@
142142
(
143143
'The database {{$labels.bdb}} in cluster {{$labels.redis_cluster}} is evicting ${{ printf "%%.0f" $value }} objects, which exceeds ' +
144144
'the threshold of %(alertsEvictedObjectsThreshold)s evicted objects.'
145-
) % $._config,
145+
) % this.config,
146146
},
147147
},
148148
],
Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,33 @@
11
{
2-
_config+:: {
3-
dashboardTags: ['redis-enterprise-mixin'],
4-
dashboardPeriod: 'now-1h',
5-
dashboardTimezone: 'default',
6-
dashboardRefresh: '1m',
2+
local this = self,
3+
filteringSelector: 'job="integrations/redis-enterprise"',
4+
groupLabels: ['job', 'redis_cluster'],
5+
instanceLabels: ['instance'],
6+
nodeLabels: ['node'],
7+
databaseLabels: ['bdb'],
8+
uid: 'redis-enterprise',
9+
dashboardNamePrefix: 'Redis Enterprise',
10+
dashboardTags: [self.uid + '-mixin'],
11+
dashboardPeriod: 'now-1h',
12+
dashboardTimezone: 'default',
13+
dashboardRefresh: '1m',
714

8-
//alert thresholds
9-
alertsClusterOutOfMemoryThreshold: 80, // %
10-
alertsNodeCPUHighUtilizationThreshold: 80, // %
11-
alertsDatabaseHighMemoryUtiliation: 80, // %
12-
alertsDatabaseHighLatencyMs: 1000, // ms
13-
alertsEvictedObjectsThreshold: 1,
15+
// Alert thresholds
16+
alertsClusterOutOfMemoryThreshold: 80, // %
17+
alertsNodeCPUHighUtilizationThreshold: 80, // %
18+
alertsDatabaseHighMemoryUtilization: 80, // %
19+
alertsDatabaseHighLatencyMs: 1000, // ms
20+
alertsEvictedObjectsThreshold: 1,
1421

15-
enableLokiLogs: true,
22+
enableLokiLogs: true,
23+
extraLogLabels: [],
24+
showLogsVolume: true,
25+
26+
// Metrics source for signals
27+
metricsSource: 'prometheus',
28+
signals: {
29+
overview: (import './signals/overview.libsonnet')(this),
30+
nodes: (import './signals/nodes.libsonnet')(this),
31+
databases: (import './signals/databases.libsonnet')(this),
1632
},
1733
}
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
local g = import './g.libsonnet';
2+
local commonlib = import 'common-lib/common/main.libsonnet';
3+
local util = import 'common-lib/common/util.libsonnet';
4+
local logslib = import 'logs-lib/logs/main.libsonnet';
5+
6+
7+
{
8+
local root = self,
9+
new(this)::
10+
local prefix = this.config.dashboardNamePrefix;
11+
local links = this.grafana.links;
12+
local tags = this.config.dashboardTags;
13+
local uid = g.util.string.slugify(this.config.uid);
14+
local vars = this.grafana.variables;
15+
local annotations = this.grafana.annotations;
16+
local refresh = this.config.dashboardRefresh;
17+
local period = this.config.dashboardPeriod;
18+
local timezone = this.config.dashboardTimezone;
19+
20+
local nodeVars = std.map(
21+
function(label)
22+
g.dashboard.variable.query.new(label)
23+
+ g.dashboard.variable.custom.selectionOptions.withMulti(true)
24+
+ g.dashboard.variable.query.queryTypes.withLabelValues(label, metric='node_up')
25+
+ g.dashboard.variable.query.withDatasourceFromVariable(vars.datasources.prometheus)
26+
+ g.dashboard.variable.query.selectionOptions.withIncludeAll(true),
27+
this.config.nodeLabels
28+
);
29+
30+
local databaseVars = std.map(
31+
function(label)
32+
g.dashboard.variable.query.new(label)
33+
+ g.dashboard.variable.custom.selectionOptions.withMulti(true)
34+
+ g.dashboard.variable.custom.selectionOptions.withIncludeAll(true)
35+
+ g.dashboard.variable.query.queryTypes.withLabelValues(label, metric='bdb_up')
36+
+ g.dashboard.variable.query.withDatasourceFromVariable(vars.datasources.prometheus), this.config.databaseLabels
37+
);
38+
39+
40+
{
41+
'redis-enterprise-overview.json':
42+
g.dashboard.new(prefix + ' overview')
43+
+ g.dashboard.withPanels(
44+
g.util.panel.resolveCollapsedFlagOnRows(
45+
g.util.grid.wrapPanels(
46+
[
47+
this.grafana.rows.overviewRow,
48+
this.grafana.rows.overviewNodesKPIsRow,
49+
this.grafana.rows.overviewDatabaseKPIsRow,
50+
]
51+
)
52+
)
53+
) + root.applyCommon(
54+
vars.multiInstance,
55+
uid + '_overview',
56+
tags,
57+
links { redisEnterpriseOverview:: {} },
58+
annotations,
59+
timezone,
60+
refresh,
61+
period,
62+
),
63+
'redis-enterprise-node-overview.json':
64+
g.dashboard.new(prefix + ' nodes')
65+
+ g.dashboard.withPanels(
66+
g.util.panel.resolveCollapsedFlagOnRows(
67+
g.util.grid.wrapPanels(
68+
[
69+
this.grafana.rows.nodesOverviewRow,
70+
this.grafana.rows.nodesMetricsRow,
71+
]
72+
)
73+
)
74+
) + root.applyCommon(
75+
vars.multiInstance + nodeVars,
76+
uid + '_nodes',
77+
tags,
78+
links { redisEnterpriseNodes:: {} },
79+
annotations,
80+
timezone,
81+
refresh,
82+
period,
83+
),
84+
'redis-enterprise-database-overview.jsonn':
85+
g.dashboard.new(prefix + ' databases')
86+
+ g.dashboard.withPanels(
87+
g.util.panel.resolveCollapsedFlagOnRows(
88+
g.util.grid.wrapPanels(
89+
[
90+
this.grafana.rows.databasesOverviewRow,
91+
this.grafana.rows.databasesMetricsRow,
92+
this.grafana.rows.databasesCRDBRow,
93+
]
94+
),
95+
)
96+
) + root.applyCommon(
97+
vars.multiInstance + nodeVars + databaseVars,
98+
uid + '_databases',
99+
tags,
100+
links { redisEnterpriseDatabases:: {} },
101+
annotations,
102+
timezone,
103+
refresh,
104+
period,
105+
),
106+
} + if this.config.enableLokiLogs then {
107+
'redis-enterprise-logs.json':
108+
logslib.new(
109+
prefix + ' logs',
110+
datasourceName=this.grafana.variables.datasources.loki.name,
111+
datasourceRegex=this.grafana.variables.datasources.loki.regex,
112+
filterSelector=this.config.filteringSelector,
113+
labels=this.config.groupLabels + this.config.extraLogLabels,
114+
formatParser=null,
115+
showLogsVolume=this.config.showLogsVolume,
116+
)
117+
{
118+
dashboards+:
119+
{
120+
logs+:
121+
root.applyCommon(super.logs.templating.list, uid=uid + '-logs', tags=tags, links=links { redisEnterpriseLogs+:: {} }, annotations=annotations, timezone=timezone, refresh=refresh, period=period),
122+
},
123+
panels+:
124+
{
125+
logs+:
126+
g.panel.logs.options.withEnableLogDetails(true)
127+
+ g.panel.logs.options.withShowTime(false)
128+
+ g.panel.logs.options.withWrapLogMessage(false),
129+
},
130+
variables+: {
131+
toArray+: [
132+
this.grafana.variables.datasources.prometheus { hide: 2 },
133+
],
134+
},
135+
}.dashboards.logs,
136+
}
137+
else {},
138+
139+
applyCommon(vars, uid, tags, links, annotations, timezone, refresh, period):
140+
g.dashboard.withTags(tags)
141+
+ g.dashboard.withUid(uid)
142+
+ g.dashboard.withLinks(std.objectValues(links))
143+
+ g.dashboard.withTimezone(timezone)
144+
+ g.dashboard.withRefresh(refresh)
145+
+ g.dashboard.time.withFrom(period)
146+
+ g.dashboard.withVariables(vars)
147+
+ g.dashboard.withAnnotations(std.objectValues(annotations)),
148+
}

redis-enterprise-mixin/dashboards/dashboards.libsonnet

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)