{"name":"Database state","description":"This metric tells you what state a specific database is in. The values translate as follows: \r\n0 = ONLINE,  1 = RESTORING, 2 = RECOVERING, 3 = RECOVERY_PENDING, 4 = SUSPECT, 5 = EMERGENCY, 6 = OFFLINE, 7 = Database Does Not Exist on Server.","tsql":"select coalesce(max(state),7)\r\nfrom   sys.databases\r\nwhere name = '<DatabaseName>' --the name should match the metric name ;","instances":true,"frequency":600,"databases":{"mode":1},"rateofchange":false,"metricenabled":true,"alertname":"Database not online","alertdescription":"This alert is based on the Database state metric. The alert is raised when the database state is no longer online.","aboveorbelow":"above","collections":1,"alertenabled":true,"_thresholds_high":{"selected":true,"value":3},"_thresholds_medium":{"selected":true,"value":1},"_thresholds_low":{"selected":true,"value":0},"name_comment":"Note: Insert the name of the database whose state you're monitoring.","thresholds_comment":"Note: Alert thresholds are directly linked to the integer values of the Database state metric on which the alert is based. By default, any value over 0 (ONLINE) requires attention. Values 1 (RESTORING) and 2 (RECOVERING) are common states, but do mean the database is unusable while the database. Values of 3 (RECOVERY_PENDING) and higher (4 = SUSPECT, 5 = EMERGENCY, 6 = OFFLINE, 7 = Database Does Not Exist on Server) indicate that the database will not be available without user intervention.\r\nThese thresholds are intended as guideline values. If they seem too high or too low, replace them with values more suited to your own server performance.","instances_comment":"Note: Alternatively, select the instance on which the specific database you're monitoring exists.","targetentitytype":0}