Animated metro map on a dark background, with coloured lines for databases, stations for tables and small trains moving along them
Data Underground: live SQL Server traffic as a metro map.

After building Workflow World, which turns K2 workflows into an animated office, we turned to SQL Server monitoring with the same aim: make it something people actually want to watch. sp_who2 tells you what is running. It doesn’t make the problems jump out.

Data Underground draws SQL Server activity as a metro map in real time. Each database is a line. Tables, views and stored procedures are stations. Each running query is a train, with passengers boarding when data is read and getting off when it is written.

The idea

Full Data Underground screen with dozens of coloured lines for SharePoint and K2 databases, controls along the top and a list of databases with session counts on the right
A real server: every line is a database, with session counts down the side.

SQL Server activity already behaves like a transport network if you look at it the right way:

  • Databases run as parallel lines across the map.
  • Tables, views and stored procedures are the stations where data is picked up or dropped off.
  • Read queries run one way and write queries the other, so you can see which way data is flowing.
  • Busier queries carry more passengers, based on how many logical reads they do.
  • A blocked session is a train held at a red signal.
  • A deadlock is two trains facing each other in the same tunnel.

Deliberately simple

The back end is a small ASP.NET Core minimal API with two endpoints, one for a snapshot of current activity and one for health. The front end is a single HTML file with a canvas. It polls every three seconds and animates the trains between polls at 60 frames a second, so the movement is smooth while the server does very little work. The only packages are Microsoft.Data.SqlClient and Dapper.

What it asks SQL Server

Each poll runs its queries in parallel against SQL Server’s dynamic management views:

  • Active requests, joined to their sessions and SQL text, pulling out the exact statement running inside a batch rather than the whole stored procedure.
  • Idle blockers: sessions that are blocking others but are not running anything themselves.
  • Recent deadlocks, read from the system_health Extended Events ring buffer, with the victims marked on the map.
  • The top wait types, to show what the server is waiting on.

The idle blocker check turned out to be the most valuable. Most monitoring looks for slow queries. Far fewer tools look for a session that opened a transaction and then just sat there, perhaps a query window left open over lunch, holding locks that everything else is queuing behind.

Seeing blocking chains

Close-up of a metro line where a hexagonal train with a padlock is linked by red dashed lines to the trains it is blocking
The head blocker gets a padlock and a red chain to every session waiting on it.

Blocking chains, where one session blocks another which blocks a third, are worked out as a simple graph search from each head blocker. On the map the head blocker gets a padlock and a red dashed line to every session it is holding up. Five trains all pointing back to one idle window is hard to miss.

Making the trains readable

Each query type has its own colour, and read queries are drawn as outlines while writes are solid, so you can tell them apart at a glance. Train size uses a logarithmic scale of logical reads. A linear scale let one heavy reporting query dominate the whole map, while a log scale lets a ten-million-read query and a thousand-read query sit side by side legibly.

Small figures step on and off at the platforms as trains stop. That part is entirely unnecessary, and it is staying.

The wait types panel

Table of wait type categories with colours: lock waits red, page I/O amber, CXPACKET purple, resource semaphore brown, async network I/O blue, write log dark red
Wait types are colour-coded by what they usually mean.

The side panel lists the top waits, grouped by what they usually indicate. Lock waits at the top suggest contention, which will probably show as a blocking chain on the map. ASYNC_NETWORK_IO at the top usually means the application, not SQL Server, is the bottleneck.

What we learned

  • Check for idle blockers. That gap is where a lot of production incidents start.
  • Use a log scale when one value can be thousands of times bigger than another.
  • A plain canvas is fast enough. The map draws in under two milliseconds a frame with more than fifty trains.
  • A good metaphor does the explaining. A DBA who had never seen the code asked within 30 seconds why one line was so busy and why one station was always red.

Running it

It needs .NET 8 and SQL Server 2016 or later. Set the connection string, grant the login VIEW SERVER STATE, and run it. It was built for fun as a weekend project rather than a production tool, so use it with care.