Skip to main content
APA
Sponsored byCAST AI — Kubernetes cost optimizationBetter Stack — Uptime monitoring and log managementVictoriaMetrics — Fast, open-source time series database and drop-in Prometheus replacement.

SQL Server logoSQL Server Prometheus Alert Rules

3 Prometheus alerting rules for SQL Server.Exported via Ozarklake/prometheus-mssql-exporter.These rules cover critical and warning conditions — copy and paste the YAML into your Prometheus configuration.

⚠️

Alert thresholds depend on the nature of your applications. Some queries may have arbitrary tolerance thresholds. Building an efficient monitoring platform takes time. 😉

wget https://raw.githubusercontent.com/samber/awesome-prometheus-alerts/refs/heads/master/dist/rules/sql-server/ozarklake-mssql-exporter.yml
critical

2.3.1.SQL Server down

SQL server instance is down

  # 1m delay allows a restart without triggering an alert.
- alert: SqlServerDown
  expr: 'mssql_up == 0'
  for: 1m
  labels:
    severity: critical
  annotations:
    summary: SQL Server down (instance {{ $labels.instance }})
    description: "SQL server instance is down\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
critical

2.3.2.SQL Server flapping

SQL Server on {{ $labels.instance }} changed state {{ $value | printf "%.0f" }} times in the last 10 minutes.

  # Catches a crash-looping service, which the down rule misses because each successful scrape resets its for: timer.
  # 4 changes means at least 2 down/up cycles in 10m; one outage followed by a recovery counts only 2.
- alert: SqlServerFlapping
  expr: 'changes(mssql_up[10m]) >= 4'
  for: 0m
  labels:
    severity: critical
  annotations:
    summary: SQL Server flapping (instance {{ $labels.instance }})
    description: "SQL Server on {{ $labels.instance }} changed state {{ $value | printf \"%.0f\" }} times in the last 10 minutes.\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
warning

2.3.3.SQL Server deadlock

SQL Server {{ $labels.instance }} is experiencing deadlocks ({{ $value }}/s)

- alert: SqlServerDeadlock
  expr: 'mssql_deadlocks > 5'
  for: 1m
  labels:
    severity: warning
  annotations:
    summary: SQL Server deadlock (instance {{ $labels.instance }})
    description: "SQL Server {{ $labels.instance }} is experiencing deadlocks ({{ $value }}/s)\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"

Share your alerting rules

Your production alerts can make this collection better. Share your rule files in one command: only Prometheus rule files and PrometheusRule resources are uploaded, while prometheus.yml, alertmanager.yml and other configurations are skipped, as they often contain credentials.

npx awesome-prometheus-alerts share /etc/prometheus/rules

Add --dry-run to preview what would be sent.