Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions discourse-mixin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ The Discourse mixin contains the following dashboards:

The Discourse mixin contains the following alerts:

- DiscourseRequestsHigh5xxErrors
- DiscourseRequestsHigh4xxErrors
- DiscourseHigh5xxErrors
- DiscourseHigh4xxErrors

## Discourse Overview

Expand Down
45 changes: 45 additions & 0 deletions discourse-mixin/alerts.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
new(this): {
groups: [
{
name: this.config.uid + '-alerts',
rules: [
{
alert: 'DiscourseHigh5xxErrors',
expr: |||
100 * rate(discourse_http_requests{status=~"5..", %(filteringSelector)s}[5m]) / on() group_left() (sum(rate(discourse_http_requests[5m])) by (instance)) > %(alertsCritical5xxResponses)s
||| % this.config,
'for': '5m',
labels: {
severity: 'critical',
},
annotations: {
summary: 'More than %(alertsCritical5xxResponses)s%% of all requests result in a 5XX.' % this.config,
description:
('{{ printf "%%.2f" $value }}%% of all requests are resulting in 500 status codes, ' +
'which is above the threshold %(alertsCritical5xxResponses)s%%, ' +
'indicating a potentially larger issue for {{$labels.instance}}') % this.config,
},
},
{
alert: 'DiscourseHigh4xxErrors',
expr: |||
100 * rate(discourse_http_requests{status=~"4..", %(filteringSelector)s}[5m]) / on() group_left() (sum(rate(discourse_http_requests[5m])) by (instance)) > %(alertsWarning4xxResponses)s
||| % this.config,
'for': '5m',
labels: {
severity: 'warning',
},
annotations: {
summary: 'More than %(alertsWarning4xxResponses)s%% of all requests result in a 4XX.' % this.config,
description:
('{{ printf "%%.2f" $value }}%% of all requests are resulting in 400 status code, ' +
'which is above the threshold %(alertsWarning4xxResponses)s%%, ' +
'indicating a potentially larger issue for {{$labels.instance}}') % this.config,
},
},
],
},
],
},
}
38 changes: 29 additions & 9 deletions discourse-mixin/config.libsonnet
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
{
_config+:: {
dashboardTags: ['discourse-mixin'],
dashboardPeriod: 'now-1h',
dashboardTimezone: 'default',
dashboardRefresh: '1m',

// for alerts
alertsCritical5xxResponses: '10', // %
alertsWarning4xxResponses: '30', // %
local this = self,

// Filtering
filteringSelector: 'job="integrations/discourse"',
groupLabels: ['job'],
instanceLabels: ['instance'],

// Dashboard settings
dashboardTags: ['discourse-mixin'],
dashboardPeriod: 'now-1h',
dashboardTimezone: 'default',
dashboardRefresh: '1m',
dashboardNamePrefix: 'Discourse',
uid: 'discourse',

// Logs configuration
enableLokiLogs: false,

// Alert thresholds
alertsCritical5xxResponses: 10, // %
alertsWarning4xxResponses: 30, // %

// Metrics source
metricsSource: 'prometheus',

// Signal categories
signals: {
overview: (import './signals/overview.libsonnet')(this),
jobs: (import './signals/jobs.libsonnet')(this),
},
}
86 changes: 86 additions & 0 deletions discourse-mixin/dashboards.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
local g = import './g.libsonnet';
local commonlib = import 'common-lib/common/main.libsonnet';

{
local root = self,
new(this):
local prefix = this.config.dashboardNamePrefix;
local links = this.grafana.links;
local tags = this.config.dashboardTags;
local uid = this.config.uid;
local vars = commonlib.variables.new(
filteringSelector=this.config.filteringSelector,
groupLabels=this.config.groupLabels,
instanceLabels=this.config.instanceLabels,
varMetric='discourse_page_views',
customAllValue='.+',
enableLokiLogs=this.config.enableLokiLogs,
);
local annotations = {};
local refresh = this.config.dashboardRefresh;
local period = this.config.dashboardPeriod;
local timezone = this.config.dashboardTimezone;

{
'discourse-overview.json':
g.dashboard.new(prefix + ' overview')
+ g.dashboard.withDescription('Overview of Discourse application performance and traffic.')
+ g.dashboard.withPanels(
g.util.panel.resolveCollapsedFlagOnRows(
g.util.grid.wrapPanels(
[
this.grafana.rows.overviewRow,
this.grafana.rows.latencyRow,
]
)
)
)
+ root.applyCommon(
vars.multiInstance,
uid + '-overview',
tags,
links { overview+:: {} },
annotations,
timezone,
refresh,
period
),

'discourse-jobs.json':
g.dashboard.new(prefix + ' jobs processing')
+ g.dashboard.withDescription('Discourse job processing, workers, and memory usage.')
+ g.dashboard.withPanels(
g.util.panel.resolveCollapsedFlagOnRows(
g.util.grid.wrapPanels(
[
this.grafana.rows.jobStatsRow,
this.grafana.rows.jobCountsRow,
this.grafana.rows.jobDurationRow,
this.grafana.rows.memoryRow,
]
)
)
)
+ root.applyCommon(
vars.multiInstance,
uid + '-jobs',
tags,
links { jobs+:: {} },
annotations,
timezone,
refresh,
period
),
},

applyCommon(vars, uid, tags, links, annotations, timezone, refresh, period):
g.dashboard.withTags(tags)
+ g.dashboard.withUid(uid)
+ g.dashboard.withLinks(std.objectValues(links))
+ g.dashboard.withTimezone(timezone)
+ g.dashboard.withRefresh(refresh)
+ g.dashboard.time.withFrom(period)
+ g.dashboard.withVariables(vars)
+ g.dashboard.withAnnotations(std.objectValues(annotations))
+ g.dashboard.graphTooltip.withSharedCrosshair(),
}
Loading
Loading