Skip to content

Commit 216eb64

Browse files
committed
Modernize wildfly-mixin to grafonnet v11 and signals architecture
1 parent d9709a2 commit 216eb64

22 files changed

+1365
-2184
lines changed

wildfly-mixin/alerts/alerts.libsonnet renamed to wildfly-mixin/alerts.libsonnet

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
2-
prometheusAlerts+:: {
2+
new(this): {
33
groups+: [
44
{
5-
name: 'wildfly',
5+
name: 'WildflyAlerts',
66
rules: [
77
{
88
alert: 'HighPercentageOfErrorResponses',
99
expr: |||
1010
sum by (job, instance, server) (increase(wildfly_undertow_error_count_total{}[5m]) / increase(wildfly_undertow_request_count_total{}[5m])) * 100 > %(alertsErrorRequestErrorRate)s
11-
||| % $._config,
11+
||| % this.config,
1212
'for': '5m',
1313
labels: {
1414
severity: 'critical',
@@ -17,23 +17,23 @@
1717
summary: 'Large percentage of requests are resulting in 5XX responses.',
1818
description: |||
1919
The percentage of error responses is {{ printf "%%.2f" $value }} on {{ $labels.instance }} - {{ $labels.server }} which is higher than {{%(alertsErrorRequestErrorRate)s }}.
20-
||| % $._config,
20+
||| % this.config,
2121
},
2222
},
2323
{
24-
alert: 'HighNumberOfRejectedSessionsForDeployment',
24+
alert: 'HighRejectedSessionsForDeployment',
2525
expr: |||
2626
sum by (deployment, instance, job) (increase(wildfly_undertow_rejected_sessions_total{}[5m])) > %(alertsErrorRejectedSessions)s
27-
||| % $._config,
27+
||| % this.config,
2828
'for': '5m',
2929
labels: {
3030
severity: 'critical',
3131
},
3232
annotations: {
3333
summary: 'Large number of sessions are being rejected for a deployment.',
3434
description: |||
35-
Deployemnt {{ $labels.deployment }} on {{ $labels.instance }} is exceeding the threshold for rejected sessions {{ printf "%%.0f" $value }} is higher than %(alertsErrorRejectedSessions)s.
36-
||| % $._config,
35+
Deployment {{ $labels.deployment }} on {{ $labels.instance }} is exceeding the threshold for rejected sessions {{ printf "%%.0f" $value }} is higher than %(alertsErrorRejectedSessions)s.
36+
||| % this.config,
3737
},
3838
},
3939
],

wildfly-mixin/config.libsonnet

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,35 @@
11
{
2-
_config+:: {
3-
enableMultiCluster: false,
4-
multiclusterSelector: 'job=~"$job"',
5-
wildflySelector: if self.enableMultiCluster then 'job=~"$job", cluster=~"$cluster"' else 'job=~"$job"',
6-
dashboardTags: ['wildfly-mixin'],
7-
dashboardPeriod: 'now-1h',
8-
dashboardTimezone: 'default',
9-
dashboardRefresh: '1m',
2+
local this = self,
3+
enableMultiCluster: false,
4+
filteringSelector: '', // set to apply static filters to all queries and alerts, i.e. job="integrations/wildfly"
5+
groupLabels: ['job', 'cluster'],
6+
logLabels: ['job', 'cluster', 'instance'],
7+
instanceLabels: ['instance'],
108

11-
// alerts thresholds
12-
alertsErrorRequestErrorRate: '30',
13-
alertsErrorRejectedSessions: '20',
9+
dashboardTags: [self.uid],
10+
uid: 'wildfly',
11+
dashboardNamePrefix: 'Wildfly',
12+
dashboardPeriod: 'now-1h',
13+
dashboardTimezone: 'default',
14+
dashboardRefresh: '1m',
15+
metricsSource: 'prometheus', // metrics source for signals
1416

15-
enableLokiLogs: true,
17+
// Logging configuration
18+
enableLokiLogs: true,
19+
extraLogLabels: ['level', 'severity'], // Required by logs-lib
20+
logsVolumeGroupBy: 'level',
21+
showLogsVolume: true,
22+
23+
// alerts thresholds
24+
alertsErrorRequestErrorRate: '30',
25+
alertsErrorRejectedSessions: '20',
26+
27+
// Signals configuration
28+
signals+: {
29+
requests: (import './signals/requests.libsonnet')(this),
30+
network: (import './signals/network.libsonnet')(this),
31+
connections: (import './signals/connections.libsonnet')(this),
32+
sessions: (import './signals/sessions.libsonnet')(this),
33+
transactions: (import './signals/transactions.libsonnet')(this),
1634
},
1735
}

wildfly-mixin/dashboards.libsonnet

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
local g = import './g.libsonnet';
2+
local commonlib = import 'common-lib/common/main.libsonnet';
3+
local logslib = import 'logs-lib/logs/main.libsonnet';
4+
{
5+
local root = self,
6+
new(this)::
7+
8+
local links = this.grafana.links;
9+
local tags = this.config.dashboardTags;
10+
local uid = g.util.string.slugify(this.config.uid);
11+
local vars = this.grafana.variables;
12+
local annotations = this.grafana.annotations;
13+
local refresh = this.config.dashboardRefresh;
14+
local period = this.config.dashboardPeriod;
15+
local timezone = this.config.dashboardTimezone;
16+
local extraLogLabels = this.config.extraLogLabels;
17+
{
18+
19+
'wildfly-overview.json':
20+
g.dashboard.new(this.config.dashboardNamePrefix + ' Overview')
21+
+ g.dashboard.withPanels(
22+
g.util.panel.resolveCollapsedFlagOnRows(
23+
g.util.grid.wrapPanels([
24+
this.grafana.rows.requestsRow,
25+
this.grafana.rows.networkRow,
26+
this.grafana.rows.sessionsRow,
27+
])
28+
)
29+
) + root.applyCommon(
30+
vars.multiInstance + [
31+
g.dashboard.variable.query.new('server')
32+
+ g.dashboard.variable.custom.selectionOptions.withMulti(true)
33+
+ g.dashboard.variable.query.queryTypes.withLabelValues(label='server', metric='wildfly_undertow_request_count_total{%(queriesSelectorGroupOnly)s}' % vars)
34+
+ g.dashboard.variable.query.withDatasourceFromVariable(vars.datasources.prometheus),
35+
g.dashboard.variable.query.new('deployment')
36+
+ g.dashboard.variable.custom.selectionOptions.withMulti(true)
37+
+ g.dashboard.variable.query.queryTypes.withLabelValues(label='deployment', metric='wildfly_undertow_active_sessions{%(queriesSelectorGroupOnly)s}' % vars)
38+
+ g.dashboard.variable.query.withDatasourceFromVariable(vars.datasources.prometheus),
39+
],
40+
uid + '-overview',
41+
tags,
42+
links { wildflyOverview+:: {} },
43+
annotations,
44+
timezone,
45+
refresh,
46+
period,
47+
),
48+
'wildfly-datasource.json':
49+
g.dashboard.new(this.config.dashboardNamePrefix + ' Datasource')
50+
+ g.dashboard.withPanels(
51+
g.util.panel.resolveCollapsedFlagOnRows(
52+
g.util.grid.wrapPanels([
53+
this.grafana.rows.connectionsRow,
54+
this.grafana.rows.transactionsRow,
55+
])
56+
)
57+
) + root.applyCommon(
58+
vars.multiInstance + [
59+
g.dashboard.variable.query.new('datasource')
60+
+ g.dashboard.variable.custom.selectionOptions.withMulti(true)
61+
+ g.dashboard.variable.query.queryTypes.withLabelValues(label='data_source', metric='wildfly_datasources_pool_in_use_count{%(queriesSelectorGroupOnly)s}' % vars)
62+
+ g.dashboard.variable.query.withDatasourceFromVariable(vars.datasources.prometheus),
63+
],
64+
uid + '-datasource',
65+
tags,
66+
links { wildflyDatasource+:: {} },
67+
annotations,
68+
timezone,
69+
refresh,
70+
period,
71+
),
72+
73+
} + if this.config.enableLokiLogs then {
74+
'wildfly-logs.json':
75+
logslib.new(
76+
this.config.dashboardNamePrefix + ' Logs',
77+
datasourceName=this.grafana.variables.datasources.loki.name,
78+
datasourceRegex=this.grafana.variables.datasources.loki.regex,
79+
filterSelector=this.config.filteringSelector,
80+
labels=this.config.groupLabels + this.config.extraLogLabels,
81+
formatParser=null,
82+
showLogsVolume=this.config.showLogsVolume,
83+
)
84+
{
85+
dashboards+:
86+
{
87+
logs+:
88+
root.applyCommon(super.logs.templating.list, uid=uid + '-logs', tags=tags, links=links { logs+:: {} }, annotations=annotations, timezone=timezone, refresh=refresh, period=period),
89+
},
90+
panels+:
91+
{
92+
logs+:
93+
g.panel.logs.options.withEnableLogDetails(true)
94+
+ g.panel.logs.options.withShowTime(false)
95+
+ g.panel.logs.options.withWrapLogMessage(false),
96+
},
97+
variables+: {
98+
toArray+: [
99+
this.grafana.variables.datasources.prometheus { hide: 2 },
100+
],
101+
},
102+
}.dashboards.logs,
103+
104+
} else {},
105+
106+
applyCommon(vars, uid, tags, links, annotations, timezone, refresh, period):
107+
g.dashboard.withTags(tags)
108+
+ g.dashboard.withUid(uid)
109+
+ g.dashboard.withLinks(std.objectValues(links))
110+
+ g.dashboard.withTimezone(timezone)
111+
+ g.dashboard.withRefresh(refresh)
112+
+ g.dashboard.time.withFrom(period)
113+
+ g.dashboard.withVariables(vars)
114+
+ g.dashboard.withAnnotations(std.objectValues(annotations)),
115+
}

wildfly-mixin/dashboards/dashboards.libsonnet

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

0 commit comments

Comments
 (0)