Skip to content

czantoine/microsoft-sql-server-with-grafana

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

49 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

License: MIT Linkedin Issues Last Commit Stars

๐Ÿ”ฎ Monitoring Microsoft SQL Server with Grafana

Grafana Dashboard Badge

Pure T-SQL โ€ข Zero Prometheus โ€ข 60+ Panels โ€ข 8 Sections

A comprehensive Grafana dashboard for monitoring Microsoft SQL Server using only native T-SQL DMVs โ€” no exporters, no Prometheus, no agents. Just connect Grafana directly to your SQL Server and get full observability.

The detailed list of all exported metrics and their SQL queries is maintained here.

A Docker Compose quickstart is available if you want to test the dashboard in minutes. Available here.


โœจ What's New (v2)

Feature Description
๐Ÿฉบ Health Score Composite gauge (0-100) combining PLE, blocking, memory grants, and cache hit ratio
โšก Signal vs Resource Waits Instantly identify CPU pressure vs I/O pressure
๐Ÿ”„ Index Fragmentation Table with rebuild/reorganize recommendations
๐Ÿ—‘ Unused Indexes Detect wasted space from indexes that cost writes but get zero reads
๐Ÿ“ก Network I/O by Client Bytes sent/received per client IP
๐Ÿ”Œ Connections by App Donut chart showing which applications connect
๐Ÿ” Sysadmin Audit Security table listing all sysadmin role members
๐Ÿ’ฟ Physical Reads & Writes Two new query performance panels for disk-level I/O
๐Ÿ”“ Open Transactions Long-running transactions that may cause blocking
๐Ÿ”„ Session Status Donut breakdown of running/sleeping/dormant sessions
๐Ÿ“Š Key Counters Transactions/s, Page Splits/s, Full Scans/s, Lock Waits/s
๐Ÿ’ป Memory Overview Total/Target/Available/Used server memory in one view

๐Ÿ“Š Dashboard Sections

๐Ÿ”ฎ Overview

At-a-glance view of your SQL Server instance health, including the Health Score gauge, version info, key performance counters, connections by application, session status breakdown, and network I/O per client.

  • Health Score: Composite 0-100 gauge (PLE + blocking + memory grants + cache hit)
  • Server Info: Database, Version, Edition, Server Name, Uptime, Online DBs
  • Key Counters: Batch Requests/s, Transactions/s, Page Splits/s, Full Scans/s, Lock Waits/s
  • Sessions: Active sessions by login, connections by application (donut), session status (donut)
  • Network: Network I/O per client IP (bytes sent/received)
  • Start Time: SQL Server start timestamp

grafana_dashboard_microsoft_sql_server_section_general

โšก Query Performance

Deep dive into query-level performance with six different Top 10 rankings, compilation stats, and a live running requests table.

  • ๐Ÿข Top 10 Slowest Queries (avg elapsed time)
  • ๐Ÿ”ฅ Top 10 CPU-Heavy Queries (total worker time)
  • ๐Ÿ“– Top 10 I/O-Heavy Queries (logical reads)
  • ๐Ÿ” Top 10 Most Executed Queries (execution count)
  • ๐Ÿ’ฟ Top 10 Physical Reads Queries (disk reads)
  • โœ๏ธ Top 10 Write-Heavy Queries (logical writes)
  • Compilation & Cache Stats: Compilations/s, Re-Compilations/s, Cache Hit %
  • Plan Cache by Type: Donut chart (Adhoc, Prepared, Proc, Trigger)
  • ๐Ÿƒ Currently Running Requests: Live table with SID, status, elapsed time, CPU, reads, query text
  • Gauges: Cache Hit %, Active Transactions

grafana_dashboard_microsoft_sql_server_section_query_performance

๐Ÿ–ฅ Server Performance & Waits

Server-level performance indicators including wait analysis, lock distribution, blocking detection, and scheduler health.

  • โณ Top 15 Wait Types (LCD bar gauge, excludes benign waits)
  • ๐Ÿ”’ Lock Distribution (stacked bar chart by mode and status)
  • โšก Signal vs Resource Waits: CPU pressure (signal) vs I/O pressure (resource) with percentage
  • Thread & I/O Status: Running, Sleeping, Blocked, Pending I/O
  • โ›” Active Blocking Chains: Live table with blocker SID, wait type, wait time, query text
  • ๐Ÿ”“ Open Transactions: Long-running transactions with session details and duration
  • TempDB Allocation: Donut chart (user vs internal objects)
  • ๐Ÿ’ฟ I/O Stall per DB File: LCD bar gauge showing read/write stalls
  • ๐Ÿ”ง Scheduler Health: Bar chart per scheduler (tasks, runnable, workers, queued)

grafana_dashboard_microsoft_sql_server_section_server_performance

๐Ÿง  Memory & Buffer

Memory pressure indicators, buffer pool analysis, and memory allocation breakdown.

  • ๐Ÿ“„ Page Life Expectancy: Gauge with threshold labels (300s = warning, 600s = good)
  • โš ๏ธ Memory Grants Pending: Gauge (non-zero = memory pressure)
  • ๐Ÿง  Buffer Pool Breakdown: Buffer Pool MB, Dirty Pages MB, Clean Pages MB
  • ๐Ÿ’ป Memory Overview: Total Server, Target Server, Available, Used (combined stat panel)
  • ๐Ÿ— Top 10 Memory Clerks: Where SQL Server allocates memory
  • Buffer per Database: Donut chart showing buffer pool distribution across databases
  • ๐Ÿ“Š Index Usage: Bar chart with seeks, scans, lookups, updates per table (log scale)

grafana_dashboard_microsoft_sql_server_section_buffer_and_index_management

๐Ÿ”„ Index Health

Proactive index maintenance insights powered by sys.dm_db_index_physical_stats and sys.dm_db_index_usage_stats.

  • ๐Ÿ”„ Index Fragmentation: Table with fragmentation %, page count, and recommended action (OK / REORGANIZE / REBUILD)
  • ๐Ÿ—‘ Unused Indexes: Indexes with zero reads but ongoing write cost โ€” candidates for removal

grafana_dashboard_microsoft_sql_server_section_index

๐Ÿ’ฟ Database Space

Storage monitoring including database sizes, log space, file distribution, table sizes, and backup history.

  • ๐Ÿ“Š Database Sizes: Horizontal bar chart (all databases > system DBs)
  • ๐Ÿ“ Transaction Log Space: Via DBCC SQLPERF(LOGSPACE)
  • ๐Ÿ“ File Distribution: Donut chart of all database files
  • ๐Ÿ“ Top 15 Tables by Size: Bar gauge
  • ๐Ÿ’พ Backup History: Table with database, start/finish, size
  • ๐Ÿ“Š Data Overview: Tables count, Total Rows, Missing Indexes count
  • ๐Ÿ” Missing Index Suggestions: Table from query optimizer with equality/inequality columns and estimated impact

grafana_dashboard_microsoft_sql_server_section_database_space_usage

๐Ÿ”’ Security & Errors

Security audit and error monitoring.

  • ๐Ÿ”‘ Security Counters: Logins, Logouts, Deadlocks, Errors/sec (combined stat panel)
  • ๐Ÿ” Sysadmin Members: Table listing all active logins with sysadmin role
  • ๐Ÿ—„ Database States: Table with state (color-mapped: ONLINE/OFFLINE/SUSPECT), recovery model, compatibility level, collation

grafana_dashboard_microsoft_sql_server_section_security

โฐ Jobs Monitoring

SQL Agent job observability.

  • ๐Ÿ“… Job Frequency (7d): Execution count per job over the last 7 days
  • ๐Ÿ”„ Running Jobs: Currently executing jobs with duration
  • ๐Ÿ“‹ Scheduled Jobs: Upcoming jobs with status (Running/Scheduled color-coded)
  • ๐Ÿ“œ Job History: Recent job executions with duration
  • โŒ Failed Jobs: Failed job details with error messages

grafana_dashboard_microsoft_sql_server_section_jobs_monitoring


๐Ÿš€ Quick Start

Option 1: Docker Compose (recommended for testing)

See the full quickstart guide for details.

Option 2: Import directly

  1. Add a Microsoft SQL Server data source in Grafana pointing to your instance
  2. Import the dashboard from Grafana.com (ID: 21378)
  3. Select your MSSQL data source and enjoy

Data Source Configuration

Parameter Value
Host your-server:1433
Database Your target database
User SA or a dedicated monitoring user
Encrypt false for local/Docker, true for production

Tip: For production, create a dedicated monitoring login with VIEW SERVER STATE and VIEW ANY DEFINITION permissions instead of using SA.


๐Ÿค Contributing

All contributions are welcome! Whether bug fixes, improvements, or new panels โ€” feel free to open a PR or issue.

If you find this project useful, please give it a star โญ๏ธ ! Your support is greatly appreciated.

Stargazers over time

Stargazers over time