Database Health State

Microsoft.SqlServer.Azure.UnitMonitor.DatabaseState (UnitMonitor)

This monitor checks the health state of the Database.
Note that in order to prevent incorrect data collection, the value of Interval (seconds) overridable parameter should not be set lower than the default value.

Knowledge Base article:

Summary

This monitor checks the health state of the Database.

Note that in order to prevent incorrect data collection, the value of Interval (seconds) overridable parameter should not be set lower than the default value.

Causes

Unhealthy state is caused by the database being unavailable. A database can be unavailable if one of the following conditions is true:

Resolutions

Examine the state of the database using the following query and then take appropriate action based on the results: SELECT DATABASEPROPERTYEX(' dbname ','Status')

ONLINE

Database is now healthy and available. No action required.

OFFLINE

Determine why the database was set offline. When appropriate, bring the database online.

RESTORING

Restore is proceeding. Restore with recovery should be performed in order for database to come online.

RECOVERING

No action is required. The database will automatically come online once the recovery process is complete.

RECOVERY PENDING

A resource-related error occurred during recovery. Administrator intervention is required before the database can come back online.

SUSPECT

The database is damaged and requires administrator intervention to repair and bring online.

COPYING

No action is required. The database will automatically come online once the copying process is complete.

Overrideable Parameters

Name

Description

Default Value

Alert Priority

Defines Alert Priority.

Normal

Alert Severity

Defines Alert Severity.

MatchMonitorHealth

Enabled

Enables or disables the workflow.

Yes

Generates Alerts

Defines whether the workflow generates an Alert.

Yes

Interval (seconds)

The recurring interval of time in seconds in which to run the workflow.

900

Monitoring Mode

Defines monitoring mode.

$Target/Host/Property[Type="Microsoft.SqlServer.Azure.Server"]/MonitoringMode$

Request timeout (seconds)

Gets or sets the timespan to wait before the request times out.

60

Synchronization Time

The synchronization time specified by using a 24-hour format. May be omitted.

 

Timeout (seconds)

Specifies the time the workflow is allowed to run before being closed and marked as failed.

600

Timeout for database connection (seconds)

A period in which the workflow must establish connection to the database.

30

Element properties:

TargetMicrosoft.SqlServer.Azure.UserDatabase
Parent MonitorSystem.Health.AvailabilityState
CategoryAvailabilityHealth
EnabledTrue
Alert GenerateTrue
Alert SeverityMatchMonitorHealth
Alert PriorityNormal
Alert Auto ResolveTrue
Monitor TypeMicrosoft.SqlServer.Azure.UnitMonitorType.DatabaseState
RemotableTrue
AccessibilityPublic
Alert Message
Database is in unhealthy state
The database "{0}" hosted on server "{1}" is in unhealthy state "{2}".
RunAsDefault

Source Code:

<UnitMonitor ID="Microsoft.SqlServer.Azure.UnitMonitor.DatabaseState" TypeID="Microsoft.SqlServer.Azure.UnitMonitorType.DatabaseState" Target="Microsoft.SqlServer.Azure.UserDatabase" ParentMonitorID="Health!System.Health.AvailabilityState" Remotable="true" Priority="Normal" Accessibility="Public" Enabled="true">
<Category>AvailabilityHealth</Category>
<AlertSettings AlertMessage="Microsoft.SqlServer.Azure.UnitMonitor.DatabaseState.AlertMessage">
<AlertOnState>Error</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>MatchMonitorHealth</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Target/Property[Type="Microsoft.SqlServer.Azure.Database"]/DatabaseName$</AlertParameter1>
<AlertParameter2>$Target/Property[Type="Microsoft.SqlServer.Azure.Database"]/ServerName$</AlertParameter2>
<AlertParameter3>$Data/Context/Property[@Name='State Name']$</AlertParameter3>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState ID="Healthy" MonitorTypeStateID="Healthy" HealthState="Success"/>
<OperationalState ID="Warning" MonitorTypeStateID="Warning" HealthState="Warning"/>
<OperationalState ID="Critical" MonitorTypeStateID="Critical" HealthState="Error"/>
</OperationalStates>
<Configuration>
<IntervalSeconds>900</IntervalSeconds>
<SyncTime/>
<TimeoutSeconds>600</TimeoutSeconds>
<ServerName>$Target/Property[Type="Microsoft.SqlServer.Azure.Database"]/ServerName$</ServerName>
<DatabaseName>$Target/Property[Type="Microsoft.SqlServer.Azure.Database"]/DatabaseName$</DatabaseName>
<UseRest>$Target/Host/Property[Type="Microsoft.SqlServer.Azure.Server"]/UseREST$</UseRest>
<MonitoringMode>$Target/Host/Property[Type="Microsoft.SqlServer.Azure.Server"]/MonitoringMode$</MonitoringMode>
<AuthorityDetails>$Target/Host/Property[Type="Microsoft.SqlServer.Azure.Server"]/AuthorityDetails$</AuthorityDetails>
<SubscriptionId>$Target/Host/Property[Type="Microsoft.SqlServer.Azure.Server"]/Subscription$</SubscriptionId>
<ResourceGroupName>$Target/Host/Property[Type="Microsoft.SqlServer.Azure.Server"]/ResourceGroupName$</ResourceGroupName>
<SqlTimeoutSeconds>30</SqlTimeoutSeconds>
<HttpTimeoutSeconds>60</HttpTimeoutSeconds>
<ResourceName>$Target/Property[Type="Microsoft.SqlServer.Azure.Database"]/DatabaseName$</ResourceName>
</Configuration>
</UnitMonitor>