{"name":"Current role of database 'InsertDatabaseNameHere'","description":"<p>This metric returns the current role of this database within your mirroring set up. Roles are represented by the following values:<\/p>\r\n<ul>\r\n<li>1 = Principal<\/li>\r\n<li>2 = Mirror<\/li>\r\n<\/ul>","tsql":"DECLARE\t@MonitorResults AS TABLE (\r\n\tdatabase_name VARCHAR(255),\r\n\trole INT,\r\n\tmirror_state TINYINT,\r\n\twitness_status TINYINT,\r\n\tlog_generat_rate INT,\r\n\tunsent_log INT,\r\n\tsent_rate INT,\r\n\tunrestored_log INT,\r\n\trecovery_rate INT,\r\n\ttransaction_delay INT,\r\n\ttransaction_per_sec INT,\r\n\taverage_delay INT,\r\n\ttime_recorded DATETIME,\r\n\ttime_behind DATETIME,\r\n\tlocal_time DATETIME);\r\n \r\nINSERT\tINTO @MonitorResults\r\n\t\tEXEC sp_dbmmonitorresults \r\n\t\t\t@database_name = 'InsertDatabaseNameHere',\r\n\t\t\t@mode = 0,\r\n\t\t\t@update_table = 0;\r\n \r\nSELECT role\r\nFROM\t@MonitorResults;\r\n","instances":true,"frequency":60,"databases":{"mode":1},"rateofchange":false,"metricenabled":true,"alertname":"Database 'InsertDatabaseNameHere' role changed","alertdescription":"This alert is raised when the role of the database changes from principal to mirror. The value returned by the metric on which this alert is based is either:\r\n<ul>\r\n<li>1 = Principal<\/li>\r\n<li>2 = Mirror<\/li>\r\n<\/ul>","aboveorbelow":"above","collections":1,"alertenabled":true,"_thresholds_high":{"selected":true,"value":1},"_thresholds_medium":{"selected":false},"_thresholds_low":{"selected":false},"tsql_comment":"Note: Replace 'InsertDatabaseNameHere' with the name of the database you're monitoring.","name_comment":"Note: Replace 'InsertDatabaseNameHere' with the name of the database you're monitoring.","targetentitytype":0}