Tracking the Number of Active Sessions on a Database Using SQL Monitor

The author creates a simple custom metric to track the number of sessions that have recently done a read or write on a database. Having established a baseline for the metric, you'll be able to spot and investigate the cause of any wild deviations from normal behavior.

It's surprisingly useful to know the number of active sessions on each of the databases on your servers. With a bit of SQL, we can create a custom metric to track how many sessions recently performed reads or writes on a database, such as in the last ten minutes. Once SQL Monitor is attuned to the usual ebbs and flows in this figure, you'll have a baseline for each database and will be able to spot suspicious or unusual patterns of usage. At this point, there are plenty of ways in SQL to find out, in detail, which users are active and what they are up to.