MSSQL on Windows: SQL Server DB Engine is restarted

Microsoft.SQLServer.Windows.EventRule.DBEngine.ServiceRestart (Rule)

Detects SQL Server DB Engine restart. Note that this rule is disabled by default. Use overrides to enable it when necessary.

Knowledge Base article:

Summary

This rule detects restart of SQL Server.

Configuration

This rule detects that SQL DB Engine service was in the "Stopped" state during some short period and turned back to the “Running” state after that. The allowed duration of unavailability is defined by the "Unavailable Time" parameter and could be overridden. By default, this value is 900 seconds (15 minutes).

Overridable Parameters

Name

Description

Default Value

Enabled

Enables or disables the workflow.

No

Priority

Defines Alert Priority.

1

Severity

Defines Alert Severity.

1

Timeout (seconds)

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

300

Timeout for query execution (seconds)

The workflow will fail and register an event, if the query execution takes longer than the specified period.

60

Timeout for database connection (seconds)

The workflow will fail and register an event, if it cannot access the database during the specified period.

15

Unavailable Time (seconds)

The workflow will try to catch a service start event during this time frame, after event service stops.

900

Element properties:

TargetMicrosoft.SQLServer.Windows.DBEngine
CategoryAvailabilityHealth
EnabledFalse
Alert GenerateTrue
Alert SeverityWarning
Alert PriorityNormal
RemotableTrue
Alert Message
MSSQL on Windows: SQL Server DB Engine is restarted
SQL Server DB Engine has been restarted on SQL Server instance "{1}", computer "{0}".

Member Modules:

ID Module Type TypeId RunAs 
ServiceRestart DataSource Microsoft.SQLServer.Windows.DataSource.DBEngineServiceRestart Default
GenerateAlert WriteAction System.Health.GenerateAlert Default

Source Code:

<Rule ID="Microsoft.SQLServer.Windows.EventRule.DBEngine.ServiceRestart" Enabled="false" Target="SqlDiscW!Microsoft.SQLServer.Windows.DBEngine" ConfirmDelivery="true" Remotable="true" Priority="Normal" DiscardLevel="100">
<Category>AvailabilityHealth</Category>
<DataSources>
<DataSource ID="ServiceRestart" TypeID="Microsoft.SQLServer.Windows.DataSource.DBEngineServiceRestart">
<MachineName>$Target/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.DBEngine"]/MachineName$</MachineName>
<NetbiosComputerName>$Target/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.DBEngine"]/NetbiosComputerName$</NetbiosComputerName>
<InstanceName>$Target/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.DBEngine"]/InstanceName$</InstanceName>
<ConnectionString>$Target/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.DBEngine"]/ConnectionString$</ConnectionString>
<InstanceVersion>$Target/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.DBEngine"]/Version$</InstanceVersion>
<InstanceEdition>$Target/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.DBEngine"]/Edition$</InstanceEdition>
<MonitoringType>$Target/Property[Type="SqlDiscW!Microsoft.SQLServer.Windows.DBEngine"]/MonitoringType$</MonitoringType>
<TimeoutSeconds>300</TimeoutSeconds>
<SqlExecTimeoutSeconds>60</SqlExecTimeoutSeconds>
<SqlTimeoutSeconds>15</SqlTimeoutSeconds>
<CorrelatorInterval>900</CorrelatorInterval>
</DataSource>
</DataSources>
<WriteActions>
<WriteAction ID="GenerateAlert" TypeID="Health!System.Health.GenerateAlert">
<Priority>1</Priority>
<Severity>1</Severity>
<AlertMessageId>$MPElement[Name="Microsoft.SQLServer.Windows.EventRule.DBEngine.ServiceRestart.AlertMessage"]$</AlertMessageId>
<AlertParameters>
<AlertParameter1>$Target/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.DBEngine"]/MachineName$</AlertParameter1>
<AlertParameter2>$Target/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.DBEngine"]/InstanceName$</AlertParameter2>
</AlertParameters>
<Suppression>
<SuppressionValue/>
</Suppression>
</WriteAction>
</WriteActions>
</Rule>