Files
windows_exporter/contrib/mixin/mise.toml
T
Jan-Otto Kröpke ae5d0cca2a mixin: group alerts by collector area and add tier 1 alerts
The alerts of the mixin now come in one rule group per collector area
(windows-exporter, windows-cpu, windows-memory, windows-disk,
windows-network, windows-service, windows-system, windows-active-directory,
windows-time). Every alert names the collectors it reads and is generated
only when _config.collectors enables them, the same switch the dashboard
uses; enableActiveDirectory and enableTime set collectors.ad and
collectors.time. _config.alerts switches single alerts off by name, and an
unknown name fails the build.

New alerts for the default collectors: WindowsCollectorTimeout,
WindowsScrapeQueueTimeout, WindowsCPUSaturation (processor queue per core),
WindowsMemoryPagingHigh, WindowsNetworkUtilizationHigh,
WindowsNetworkInterfaceFlapping, WindowsServiceNotRunning (automatic
services without triggers), WindowsServiceCrashLooping (processes per
service in 15 minutes) and WindowsHostRebooted (info, fires once per
reboot). WindowsNetworkErrors and WindowsNetworkDiscards compare the error
and discard rates with the packet rate (networkErrorRatioThreshold and
networkDiscardRatioThreshold, in percent) instead of an absolute packet
rate. Threshold alerts set keep_firing_for from keepFiringFor (5m); the new
infoSeverity and serviceSelector knobs follow the existing ones.

New recordings: windows:cpu_queue_per_core:ratio,
windows:net_received_packets:rate and windows:net_sent_packets:rate.

Each new alert has a runbook, a README row and a unit test;
tests/alerts.test.jsonnet checks the collector gating, the alert switches
and the group layout. The runbook check renders the alerts of every
collector. contrib/mixin/AGENTS.md documents the checklist for new alerts.

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
2026-10-16 23:06:59 +00:00

113 lines
4.1 KiB
TOML

[tools]
"github:google/go-jsonnet" = "0.22.0"
"go:github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb" = "0.6.0"
"github:cloudflare/pint" = "0.89.2"
"github:grafana/dashboard-linter" = "0.3.0"
"github:prometheus/prometheus" = "3.15.0"
[vars]
sources = "*.libsonnet *.jsonnet lib/*.libsonnet rules/*.libsonnet alerts/*.libsonnet dashboards/*.libsonnet tests/*.libsonnet tests/*.jsonnet"
fmt_flags = "-n 2 --max-blank-lines 2 --string-style s --comment-style s"
dashboards = "../../dashboard"
[tasks.generate]
description = "Generate Prometheus rules, alerts, and the dashboard"
alias = "default"
depends = ["rules", "dashboard"]
[tasks.rules]
description = "Generate Prometheus rules and alerts"
run = [
"jsonnet -S rules.jsonnet > windows_rules.yaml",
"jsonnet -S alerts.jsonnet > windows_alerts.yaml",
]
[tasks.vendor]
description = "Install dashboard Jsonnet libraries"
run = "jb install"
[tasks.dashboard]
description = "Regenerate the committed Grafana dashboards"
alias = "dashboards"
depends = ["vendor"]
run = '''
set -eu
out=$(mktemp -d)
trap 'rm -rf "$out"' EXIT
jsonnet -J vendor -S -m "$out" dashboard.jsonnet > /dev/null
rm -f {{vars.dashboards}}/windows-exporter-*.json
cp "$out"/*.json {{vars.dashboards}}/
'''
[tasks.check-dashboards]
description = "Regenerate the dashboards and fail on uncommitted changes"
depends = ["dashboard"]
run = '''
set -eu
git add --intent-to-add -- {{vars.dashboards}}/windows-exporter-*.json
git diff --exit-code -- {{vars.dashboards}}
'''
[tasks.lint-dashboards]
description = "Lint the committed dashboards in strict mode"
run = '''
set -eu
for file in {{vars.dashboards}}/windows-exporter-*.json; do
dashboard-linter lint --strict --config .dashboard-lint.yaml "$file"
done
'''
[tasks.fmt]
description = "Format all mixin Jsonnet sources"
run = "jsonnetfmt {{vars.fmt_flags}} -i {{vars.sources}}"
[tasks.custom-rules]
description = "Generate rules and alerts with the test configuration"
hide = true
run = [
'''jsonnet -S -e 'std.manifestYamlDoc((import "tests/config.libsonnet").prometheusRules)' > tests/custom_rules.yaml''',
'''jsonnet -S -e 'std.manifestYamlDoc((import "tests/config.libsonnet").prometheusAlerts)' > tests/custom_alerts.yaml''',
]
[tasks.lint]
description = "Check Jsonnet formatting and lint, dashboard drift, and Prometheus rules"
depends = ["rules", "custom-rules", "vendor", "lint-dashboards"]
run = '''
set -eu
for file in {{vars.sources}}; do
jsonnetfmt {{vars.fmt_flags}} "$file" | diff -u "$file" -
jsonnet-lint -J vendor "$file"
done
out=$(mktemp -d)
trap 'rm -rf "$out"' EXIT
jsonnet -J vendor -S -m "$out" dashboard.jsonnet > /dev/null
(cd "$out" && ls windows-exporter-*.json) > "$out/generated"
(cd {{vars.dashboards}} && ls windows-exporter-*.json) | diff -u "$out/generated" - \
|| { echo "{{vars.dashboards}} has missing or stale dashboards; run mise run dashboard"; exit 1; }
for file in $(cat "$out/generated"); do
diff -u {{vars.dashboards}}/"$file" "$out/$file" \
|| { echo "{{vars.dashboards}}/$file is out of date; run mise run dashboard"; exit 1; }
done
promtool check rules windows_rules.yaml windows_alerts.yaml tests/custom_rules.yaml tests/custom_alerts.yaml ../../docs/upgrade/0.32.prom
pint --offline lint windows_rules.yaml windows_alerts.yaml
pint --offline lint tests/custom_rules.yaml tests/custom_alerts.yaml
'''
[tasks.check-runbooks]
description = "Check runbook coverage for all alerts, including opt-in alerts"
run = '''jsonnet -e '(import "mixin.libsonnet") { _config+:: { collectors: { [name]: true for name in std.objectFields(super.collectors) } } }.prometheusAlerts' | python3 tests/check_runbooks.py ../../docs/runbooks'''
[tasks.test]
description = "Run all mixin lint, runbook, and rule tests"
depends = ["lint", "check-runbooks", "vendor"]
run = [
"jsonnet tests/runbooks.test.jsonnet",
"jsonnet tests/alerts.test.jsonnet",
"jsonnet -J vendor tests/dashboard.test.jsonnet > /dev/null",
"promtool test rules tests/*.test.yaml",
]
[tasks.clean]
description = "Remove generated rule and alert files"
run = "rm -f windows_rules.yaml windows_alerts.yaml tests/custom_rules.yaml tests/custom_alerts.yaml"