Files
windows_exporter/contrib/mixin/alerts/service.libsonnet
T
Jan-Otto Kröpke 51a579e031 mixin: one alert file per collector with plain PromQL
Split alerts/alerts.libsonnet into one file per collector under alerts/,
like kubernetes-mixin. Each rule is a plain Prometheus alerting rule with
the PromQL written out in an expr block and %(name)s placeholders for the
_config values; lib/alerts.libsonnet keeps the collector and per-alert
gating and keep_firing_for. The pagefile, diskdrive and license alerts
get groups of their own so that one file is one group. The rendered
default rules are unchanged apart from expr block scalars.

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2026-10-17 14:53:14 +00:00

39 lines
1.9 KiB
Jsonnet

{
local c = self._config,
local a = (import '../lib/alerts.libsonnet')(c),
prometheusAlerts+:: {
groups+: a.group('windows-service', collectors=['service'], rules=[
{
alert: 'WindowsServiceNotRunning',
// The matches ignore only the labels of the right-hand metric, so
// every target label, including ones a selector adds, takes part.
expr: |||
max without (state) (windows_service_state{%(windowsExporterSelector)s, %(serviceSelector)s, state="running"} == 0)
and ignoring (start_mode) (windows_service_start_mode{%(windowsExporterSelector)s, %(serviceSelector)s, start_mode="auto"} == 1)
unless ignoring (display_name, run_as, path_name, delayed_start, trigger_start) (windows_service_info{%(windowsExporterSelector)s, %(serviceSelector)s, trigger_start="true"} == 1)
||| % c,
'for': '15m',
labels: { severity: 'warning' },
annotations: {
summary: 'Windows automatic service is not running',
description: 'Service {{ $labels.service }} on {{ $labels.instance }} starts automatically but has not been running for 15 minutes.',
},
state:: true,
},
{
alert: 'WindowsServiceCrashLooping',
// Every service process has its own series, so the series seen in the
// window count the processes the service ran as.
expr: |||
count without (process_id) (count_over_time(windows_service_process{%(windowsExporterSelector)s, %(serviceSelector)s}[15m])) - 1 > %(serviceRestartThreshold)s
||| % c,
labels: { severity: 'warning' },
annotations: {
summary: 'Windows service is restarting repeatedly',
description: 'Service {{ $labels.service }} on {{ $labels.instance }} has restarted more than %(serviceRestartThreshold)s times in 15 minutes.' % c,
},
},
]),
},
}