Skip to content

Commit b679d0e

Browse files
authored
chore: Discourse Mixin Modernization (grafana#1539)
* modernize the discourse mixin * remove .lint addition * update readme for alerts rename * update import so that it uses the jsonnetfile.json * pr feedback; minus validation on histogram switch * add grafonnet dependency to jsonnetfile.json * PR feedback; histogram cleanups * make dashboards_out * forgot to change signal type to raw for histogram change * add stacking to histogram
1 parent c55e8f4 commit b679d0e

File tree

16 files changed

+1205
-1074
lines changed

16 files changed

+1205
-1074
lines changed

discourse-mixin/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ The Discourse mixin contains the following dashboards:
99

1010
The Discourse mixin contains the following alerts:
1111

12-
- DiscourseRequestsHigh5xxErrors
13-
- DiscourseRequestsHigh4xxErrors
12+
- DiscourseHigh5xxErrors
13+
- DiscourseHigh4xxErrors
1414

1515
## Discourse Overview
1616

discourse-mixin/alerts.libsonnet

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
new(this): {
3+
groups: [
4+
{
5+
name: this.config.uid + '-alerts',
6+
rules: [
7+
{
8+
alert: 'DiscourseHigh5xxErrors',
9+
expr: |||
10+
100 * rate(discourse_http_requests{status=~"5..", %(filteringSelector)s}[5m]) / on() group_left() (sum(rate(discourse_http_requests[5m])) by (instance)) > %(alertsCritical5xxResponses)s
11+
||| % this.config,
12+
'for': '5m',
13+
labels: {
14+
severity: 'critical',
15+
},
16+
annotations: {
17+
summary: 'More than %(alertsCritical5xxResponses)s%% of all requests result in a 5XX.' % this.config,
18+
description:
19+
('{{ printf "%%.2f" $value }}%% of all requests are resulting in 500 status codes, ' +
20+
'which is above the threshold %(alertsCritical5xxResponses)s%%, ' +
21+
'indicating a potentially larger issue for {{$labels.instance}}') % this.config,
22+
},
23+
},
24+
{
25+
alert: 'DiscourseHigh4xxErrors',
26+
expr: |||
27+
100 * rate(discourse_http_requests{status=~"4..", %(filteringSelector)s}[5m]) / on() group_left() (sum(rate(discourse_http_requests[5m])) by (instance)) > %(alertsWarning4xxResponses)s
28+
||| % this.config,
29+
'for': '5m',
30+
labels: {
31+
severity: 'warning',
32+
},
33+
annotations: {
34+
summary: 'More than %(alertsWarning4xxResponses)s%% of all requests result in a 4XX.' % this.config,
35+
description:
36+
('{{ printf "%%.2f" $value }}%% of all requests are resulting in 400 status code, ' +
37+
'which is above the threshold %(alertsWarning4xxResponses)s%%, ' +
38+
'indicating a potentially larger issue for {{$labels.instance}}') % this.config,
39+
},
40+
},
41+
],
42+
},
43+
],
44+
},
45+
}

discourse-mixin/config.libsonnet

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,32 @@
11
{
2-
_config+:: {
3-
dashboardTags: ['discourse-mixin'],
4-
dashboardPeriod: 'now-1h',
5-
dashboardTimezone: 'default',
6-
dashboardRefresh: '1m',
7-
8-
// for alerts
9-
alertsCritical5xxResponses: '10', // %
10-
alertsWarning4xxResponses: '30', // %
2+
local this = self,
3+
4+
// Filtering
5+
filteringSelector: 'job="integrations/discourse"',
6+
groupLabels: ['job'],
7+
instanceLabels: ['instance'],
8+
9+
// Dashboard settings
10+
dashboardTags: ['discourse-mixin'],
11+
dashboardPeriod: 'now-1h',
12+
dashboardTimezone: 'default',
13+
dashboardRefresh: '1m',
14+
dashboardNamePrefix: 'Discourse',
15+
uid: 'discourse',
16+
17+
// Logs configuration
18+
enableLokiLogs: false,
19+
20+
// Alert thresholds
21+
alertsCritical5xxResponses: 10, // %
22+
alertsWarning4xxResponses: 30, // %
23+
24+
// Metrics source
25+
metricsSource: 'prometheus',
26+
27+
// Signal categories
28+
signals: {
29+
overview: (import './signals/overview.libsonnet')(this),
30+
jobs: (import './signals/jobs.libsonnet')(this),
1131
},
1232
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
local g = import './g.libsonnet';
2+
local commonlib = import 'common-lib/common/main.libsonnet';
3+
4+
{
5+
local root = self,
6+
new(this):
7+
local prefix = this.config.dashboardNamePrefix;
8+
local links = this.grafana.links;
9+
local tags = this.config.dashboardTags;
10+
local uid = this.config.uid;
11+
local vars = commonlib.variables.new(
12+
filteringSelector=this.config.filteringSelector,
13+
groupLabels=this.config.groupLabels,
14+
instanceLabels=this.config.instanceLabels,
15+
varMetric='discourse_page_views',
16+
customAllValue='.+',
17+
enableLokiLogs=this.config.enableLokiLogs,
18+
);
19+
local annotations = {};
20+
local refresh = this.config.dashboardRefresh;
21+
local period = this.config.dashboardPeriod;
22+
local timezone = this.config.dashboardTimezone;
23+
24+
{
25+
'discourse-overview.json':
26+
g.dashboard.new(prefix + ' overview')
27+
+ g.dashboard.withDescription('Overview of Discourse application performance and traffic.')
28+
+ g.dashboard.withPanels(
29+
g.util.panel.resolveCollapsedFlagOnRows(
30+
g.util.grid.wrapPanels(
31+
[
32+
this.grafana.rows.overviewRow,
33+
this.grafana.rows.latencyRow,
34+
]
35+
)
36+
)
37+
)
38+
+ root.applyCommon(
39+
vars.multiInstance,
40+
uid + '-overview',
41+
tags,
42+
links { overview+:: {} },
43+
annotations,
44+
timezone,
45+
refresh,
46+
period
47+
),
48+
49+
'discourse-jobs.json':
50+
g.dashboard.new(prefix + ' jobs processing')
51+
+ g.dashboard.withDescription('Discourse job processing, workers, and memory usage.')
52+
+ g.dashboard.withPanels(
53+
g.util.panel.resolveCollapsedFlagOnRows(
54+
g.util.grid.wrapPanels(
55+
[
56+
this.grafana.rows.jobStatsRow,
57+
this.grafana.rows.jobCountsRow,
58+
this.grafana.rows.jobDurationRow,
59+
this.grafana.rows.memoryRow,
60+
]
61+
)
62+
)
63+
)
64+
+ root.applyCommon(
65+
vars.multiInstance,
66+
uid + '-jobs',
67+
tags,
68+
links { jobs+:: {} },
69+
annotations,
70+
timezone,
71+
refresh,
72+
period
73+
),
74+
},
75+
76+
applyCommon(vars, uid, tags, links, annotations, timezone, refresh, period):
77+
g.dashboard.withTags(tags)
78+
+ g.dashboard.withUid(uid)
79+
+ g.dashboard.withLinks(std.objectValues(links))
80+
+ g.dashboard.withTimezone(timezone)
81+
+ g.dashboard.withRefresh(refresh)
82+
+ g.dashboard.time.withFrom(period)
83+
+ g.dashboard.withVariables(vars)
84+
+ g.dashboard.withAnnotations(std.objectValues(annotations))
85+
+ g.dashboard.graphTooltip.withSharedCrosshair(),
86+
}

0 commit comments

Comments
 (0)