Skip to content

MSSQL Modernization #1450

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
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
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
{
prometheusAlerts+:: {
groups+: [
new(this): {
groups: [
{
name: 'MSSQLAlerts',
rules: [
{
alert: 'MSSQLHighNumberOfDeadlocks',
expr: |||
increase(mssql_deadlocks_total{}[5m]) > %(alertsWarningDeadlocks5m)s
||| % $._config,
||| % this.config,
'for': '5m',
labels: {
severity: 'warning',
},
annotations: {
summary: 'There are deadlocks ocurring in the database.',
summary: 'There are deadlocks occurring in the database.',
description:
('{{ printf "%%.2f" $value }} deadlocks have occurred over the last 5 minutes on {{$labels.instance}}, ' +
'which is above threshold of %(alertsWarningDeadlocks5m)s deadlocks.') % $._config,
'which is above threshold of %(alertsWarningDeadlocks5m)s deadlocks.') % this.config,
},
},
{
alert: 'MSSQLModerateReadStallTime',
expr: |||
1000 * increase(mssql_io_stall_seconds_total{operation="read"}[5m]) > %(alertsWarningModerateReadStallTimeMS)s
||| % $._config,
||| % this.config,
'for': '5m',
labels: {
severity: 'warning',
Expand All @@ -33,14 +33,14 @@
summary: 'There is a moderate amount of IO stall for database reads.',
description:
('{{ printf "%%.2f" $value }}ms of IO read stall has occurred on {{$labels.instance}}, ' +
'which is above threshold of %(alertsWarningModerateReadStallTimeMS)sms.') % $._config,
'which is above threshold of %(alertsWarningModerateReadStallTimeMS)sms.') % this.config,
},
},
{
alert: 'MSSQLHighReadStallTime',
expr: |||
1000 * increase(mssql_io_stall_seconds_total{operation="read"}[5m]) > %(alertsCriticalHighReadStallTimeMS)s
||| % $._config,
||| % this.config,
'for': '5m',
labels: {
severity: 'critical',
Expand All @@ -49,14 +49,14 @@
summary: 'There is a high amount of IO stall for database reads.',
description:
('{{ printf "%%.2f" $value }}ms of IO read stall has occurred on {{$labels.instance}}, ' +
'which is above threshold of %(alertsCriticalHighReadStallTimeMS)sms.') % $._config,
'which is above threshold of %(alertsCriticalHighReadStallTimeMS)sms.') % this.config,
},
},
{
alert: 'MSSQLModerateWriteStallTime',
expr: |||
1000 * increase(mssql_io_stall_seconds_total{operation="write"}[5m]) > %(alertsWarningModerateWriteStallTimeMS)s
||| % $._config,
||| % this.config,
'for': '5m',
labels: {
severity: 'warning',
Expand All @@ -65,14 +65,14 @@
summary: 'There is a moderate amount of IO stall for database writes.',
description:
('{{ printf "%%.2f" $value }}ms of IO write stall has occurred on {{$labels.instance}}, ' +
'which is above threshold of %(alertsWarningModerateWriteStallTimeMS)sms.') % $._config,
'which is above threshold of %(alertsWarningModerateWriteStallTimeMS)sms.') % this.config,
},
},
{
alert: 'MSSQLHighWriteStallTime',
expr: |||
1000 * increase(mssql_io_stall_seconds_total{operation="write"}[5m]) > %(alertsCriticalHighWriteStallTimeMS)s
||| % $._config,
||| % this.config,
'for': '5m',
labels: {
severity: 'critical',
Expand All @@ -81,7 +81,7 @@
summary: 'There is a high amount of IO stall for database writes.',
description:
('{{ printf "%%.2f" $value }}ms of IO write stall has occurred on {{$labels.instance}}, ' +
'which is above threshold of %(alertsCriticalHighWriteStallTimeMS)sms.') % $._config,
'which is above threshold of %(alertsCriticalHighWriteStallTimeMS)sms.') % this.config,
},
},
],
Expand Down
50 changes: 34 additions & 16 deletions mssql-mixin/config.libsonnet
Original file line number Diff line number Diff line change
@@ -1,21 +1,39 @@
{
_config+:: {
enableMultiCluster: false,
multiclusterSelector: 'job=~"$job"',
mssqlSelector: if self.enableMultiCluster then 'job=~"$job", cluster=~"$cluster"' else 'job=~"$job"',
dashboardTags: ['mssql-mixin'],
dashboardPeriod: 'now-1h',
dashboardTimezone: 'default',
dashboardRefresh: '1m',
local this = self,
enableMultiCluster: false,
filteringSelector: 'job=~"integrations/mssql"',
groupLabels: ['job', 'cluster'], // Remove 'db' from here
instanceLabels: ['instance'],

// alert thresholds
alertsWarningDeadlocks5m: 10,
alertsWarningModerateReadStallTimeMS: 200,
alertsCriticalHighReadStallTimeMS: 400,
alertsWarningModerateWriteStallTimeMS: 200,
alertsCriticalHighWriteStallTimeMS: 400,

// enable Loki logs
enableLokiLogs: true,
dashboardTags: [self.uid],
legendLabels: ['instance'],
uid: 'mssql',
dashboardNamePrefix: 'MSSQL',

// additional params
dashboardPeriod: 'now-1h',
dashboardTimezone: 'default',
dashboardRefresh: '1m',
metricsSource: 'prometheus',

// logs lib related
enableLokiLogs: true,
logLabels: ['job', 'cluster', 'instance'],
extraLogLabels: [], // Required by logs-lib
logsVolumeGroupBy: 'level',
showLogsVolume: true,

// alert thresholds
alertsWarningDeadlocks5m: 10,
alertsWarningModerateReadStallTimeMS: 200,
alertsCriticalHighReadStallTimeMS: 400,
alertsWarningModerateWriteStallTimeMS: 200,
alertsCriticalHighWriteStallTimeMS: 400,

signals+: {
memory: (import './signals/memory.libsonnet')(this),
connections: (import './signals/connections.libsonnet')(this),
database: (import './signals/database.libsonnet')(this),
},
}
109 changes: 109 additions & 0 deletions mssql-mixin/dashboards.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
local g = import './g.libsonnet';
local logslib = import 'logs-lib/logs/main.libsonnet';
{
local root = self,
new(this)::
local prefix = this.config.dashboardNamePrefix;
local links = this.grafana.links;
local tags = this.config.dashboardTags;
local uid = g.util.string.slugify(this.config.uid);
local vars = this.grafana.variables;
local annotations = this.grafana.annotations;
local refresh = this.config.dashboardRefresh;
local period = this.config.dashboardPeriod;
local timezone = this.config.dashboardTimezone;
local panels = this.grafana.panels;

{
'mssql_overview.json':
g.dashboard.new(prefix + ' overview')
+ g.dashboard.withPanels(
g.util.panel.resolveCollapsedFlagOnRows(
g.util.grid.wrapPanels(
[
this.grafana.rows.connections + g.panel.row.withCollapsed(false),
this.grafana.rows.memory + g.panel.row.withCollapsed(false),
this.grafana.rows.database + g.panel.row.withCollapsed(false),
],
),
)
)
+ root.applyCommon(
vars.multiInstance,
uid + '_mssql_overview',
tags,
links { mssqlOverview+:: {} },
annotations,
timezone,
refresh,
period
),

'mssql_pages.json':
g.dashboard.new(prefix + ' pages')
+ g.dashboard.withPanels(
g.util.panel.resolveCollapsedFlagOnRows(
g.util.grid.wrapPanels(
[
this.grafana.rows.pages + g.panel.row.withCollapsed(false),
]
),
)
)
+ root.applyCommon(
vars.multiInstance,
uid + '_mssql_pages',
tags,
links { mssqlPages+:: {} },
annotations,
timezone,
refresh,
period
),

}
+
if this.config.enableLokiLogs then
{
'logs.json':
logslib.new(
prefix + ' logs',
datasourceName=this.grafana.variables.datasources.loki.name,
datasourceRegex=this.grafana.variables.datasources.loki.regex,
filterSelector=this.config.filteringSelector,
labels=this.config.groupLabels + this.config.extraLogLabels,
formatParser=null,
showLogsVolume=this.config.showLogsVolume,
)
{
dashboards+:
{
logs+:
root.applyCommon(super.logs.templating.list, uid=uid + '-logs', tags=tags, links=links { logs+:: {} }, annotations=annotations, timezone=timezone, refresh=refresh, period=period),
},
panels+:
{
logs+:
g.panel.logs.options.withEnableLogDetails(true)
+ g.panel.logs.options.withShowTime(false)
+ g.panel.logs.options.withWrapLogMessage(false),
},
variables+: {
toArray+: [
this.grafana.variables.datasources.prometheus { hide: 2 },
],
},
}.dashboards.logs,
}
else {},

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)),
}
2 changes: 0 additions & 2 deletions mssql-mixin/dashboards/dashboards.libsonnet

This file was deleted.

Loading
Loading