Metrics install automatically if you have Redgate Monitor installed.
If you are using Redgate’s SQL Server monitoring tool, Redgate Monitor, you can instantly install and run this metric on your servers.
This metric queries data from an Extended Events session to detect databases being dropped, created, started, stopped, attached or detached. It assigns a configurable “anxiety index” value (an integer from 1-10) to each detected event and then calculates a total based on the occurrences of these events over a period.
First, create and start for the following Extended Events session on the monitored SQL Server instance:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
CREATE EVENT SESSION [DatabaseEvents] ON SERVER ADD EVENT sqlserver.database_attached( ACTION(sqlserver.client_app_name,sqlserver.database_name,sqlserver.sql_text,sqlserver.username)), ADD EVENT sqlserver.database_created( ACTION(sqlserver.client_app_name,sqlserver.database_name,sqlserver.sql_text,sqlserver.username)), ADD EVENT sqlserver.database_detached( ACTION(sqlserver.client_app_name,sqlserver.database_name,sqlserver.sql_text,sqlserver.username)), ADD EVENT sqlserver.database_dropped( ACTION(sqlserver.client_app_name,sqlserver.database_name,sqlserver.sql_text,sqlserver.username)), ADD EVENT sqlserver.database_started( ACTION(sqlserver.client_app_name,sqlserver.database_name,sqlserver.sql_text,sqlserver.username)), ADD EVENT sqlserver.database_stopped( ACTION(sqlserver.client_app_name,sqlserver.database_name,sqlserver.sql_text,sqlserver.username)) ADD TARGET package0.ring_buffer(SET occurrence_number=(60)) WITH (STARTUP_STATE=ON) GO ALTER EVENT SESSION DatabaseEvents ON SERVER STATE = START; |
For further details see: Checking for Database Events Using Extended Events and SQL Monitor.
Metric definition
Name
DatabaseEvents
Description
An anxiety level metric based on detection of databases being stopped, started, attached, detached, created or dropped. These actions should be unusual on a production server.
The T-SQL query that will collect data
Instances to collect from
Default
Databases to collect from
master
Collection frequency
1 min
Use collected or calculated values
Leave the Use a calculated rate of change between collections check box unchecked
Metric collection
Enabled
Alert definition
The appropriate alert threshold depends on how often these events are likely to occur on your systems. You should set the alert threshold after establishing a baseline for your working instance.