{"name":"Mirroring latency","description":"This metric measures the latency of a mirroring stream. This is useful for checking the historical status of mirroring and also alerting when mirroring is delayed. Values are displayed in seconds and calculated every minute. ","tsql":"DECLARE @MirroredDBToTest sysname\r\nSET @MirroredDBToTest = DB_NAME()\r\nDECLARE @MirroringResults TABLE \r\n(database_name sysname,\r\nrole int,\r\nmirroring_state int,\r\nwitness_status int,\r\nlog_generation_rate int,\r\nunsent_log int,\r\nsend_rate int,\r\nunrestored_log int,\r\nrecovery_rate int,\r\ntransaction_delay int,\r\ntransactions_per_sec int,\r\naverage_delay int,\r\ntime_recorded datetime,\r\ntime_behind datetime,\r\nlocal_time datetime)\r\n\r\nINSERT INTO @MirroringResults\r\nEXEC msdb..sp_dbmmonitorresults @database_name = @MirroredDBToTest\r\n\r\nSELECT DATEDIFF(S,time_behind, time_recorded) AS Latency FROM @MirroringResults","instances":false,"frequency":60,"databases":{"mode":1},"rateofchange":false,"metricenabled":true,"alertname":"Mirroring latency increased","alertdescription":"This alert is raised when the latency of a mirrored database (in seconds) is greater than the threshold specified. You may consider checking the state of the mirrored database.","aboveorbelow":"above","collections":1,"alertenabled":true,"_thresholds_high":{"selected":true,"value":259},"_thresholds_medium":{"selected":false},"_thresholds_low":{"selected":false},"targetentitytype":0}