Job Duration

Microsoft.Azure.ManagedInstance.Monitor.AgentJob.Duration (UnitMonitor)

Monitors Agent Job Duration.
Note that SQL Server Agent Service is not controlled by the user.

Knowledge Base article:

Summary

This monitor checks all jobs on the Managed Instance SQL Agent and if any of the jobs takes longer than the specified threshold, the monitor changes its state either to Warning or Critical. This does not generate an alert because there is an override to disable alerts to control noise. If you want this level of monitoring, you need to override Alerting back to enabled.

External

Automate management tasks using SQL Agent jobs in Azure SQL Managed Instance

Overridable Parameters

Name

Description

Default Value

Alert Priority

Defines Alert Priority.

Normal

Alert Severity

Defines Alert Severity.

Match monitor’s health

Critical Threshold (minutes)

The monitor will change its state to Critical if the value exceeds this threshold. Being between this threshold and the warning threshold (inclusive) will result in the monitor being in a warning state.

120

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.

600

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.

300

Timeout for database connection (seconds)

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

15

Warning Threshold (minutes)

Warning threshold. Exceeding this threshold will result in the monitor changing to at least a warning state.

60

Element properties:

TargetMicrosoft.Azure.ManagedInstance.AgentJob
Parent MonitorSystem.Health.PerformanceState
CategoryPerformanceCollection
EnabledTrue
Alert GenerateTrue
Alert SeverityMatchMonitorHealth
Alert PriorityNormal
Alert Auto ResolveTrue
Monitor TypeMicrosoft.Azure.ManagedInstance.MonitorType.AgentJob.Duration
RemotableTrue
AccessibilityPublic
Alert Message
Azure SQL MI: Agent Job Duration Critical
Execution of the agent job "{0}" is {2} minute(s).
Instance name: {1}
RunAsDefault

Source Code:

<UnitMonitor ID="Microsoft.Azure.ManagedInstance.Monitor.AgentJob.Duration" Accessibility="Public" Enabled="true" Target="MngdInstD!Microsoft.Azure.ManagedInstance.AgentJob" ParentMonitorID="Health!System.Health.PerformanceState" Remotable="true" Priority="Normal" TypeID="Microsoft.Azure.ManagedInstance.MonitorType.AgentJob.Duration" ConfirmDelivery="false">
<Category>PerformanceCollection</Category>
<AlertSettings AlertMessage="Microsoft.Azure.ManagedInstance.Monitor.AgentJob.Duration.AlertMessage">
<AlertOnState>Error</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>MatchMonitorHealth</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Target/Property[Type="MngdInstD!Microsoft.Azure.ManagedInstance.AgentJob"]/Name$</AlertParameter1>
<AlertParameter2>$Target/Host/Host/Property[Type="MngdInstD!Microsoft.Azure.ManagedInstance.DBEngine"]/InstanceName$</AlertParameter2>
<AlertParameter3>$Data/Context/Property[@Name='Duration']$</AlertParameter3>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState ID="UnderThreshold1" MonitorTypeStateID="UnderThreshold1" HealthState="Success"/>
<OperationalState ID="OverThreshold1UnderThreshold2" MonitorTypeStateID="OverThreshold1UnderThreshold2" HealthState="Warning"/>
<OperationalState ID="OverThreshold2" MonitorTypeStateID="OverThreshold2" HealthState="Error"/>
</OperationalStates>
<Configuration>
<InstanceName>$Target/Host/Host/Property[Type="MngdInstD!Microsoft.Azure.ManagedInstance.DBEngine"]/InstanceName$</InstanceName>
<Tier>$Target/Host/Host/Property[Type="MngdInstD!Microsoft.Azure.ManagedInstance.DBEngine"]/Tier$</Tier>
<HardwareGeneration>$Target/Host/Host/Property[Type="MngdInstD!Microsoft.Azure.ManagedInstance.DBEngine"]/HardwareGeneration$</HardwareGeneration>
<ReadScaleOutReplicaType>$Target/Host/Host/Property[Type="MngdInstD!Microsoft.Azure.ManagedInstance.DBEngine"]/ReadScaleOutReplicaType$</ReadScaleOutReplicaType>
<ConnectionString>$Target/Host/Host/Property[Type="MngdInstD!Microsoft.Azure.ManagedInstance.DBEngine"]/ConnectionString$</ConnectionString>
<AuthType>$Target/Host/Host/Property[Type="MngdInstD!Microsoft.Azure.ManagedInstance.DBEngine"]/AuthType$</AuthType>
<AuthorityDetails>$Target/Host/Host/Property[Type="MngdInstD!Microsoft.Azure.ManagedInstance.DBEngine"]/AuthorityDetails$</AuthorityDetails>
<JobName>$Target/Property[Type="MngdInstD!Microsoft.Azure.ManagedInstance.AgentJob"]/Name$</JobName>
<Threshold1>60</Threshold1>
<Threshold2>120</Threshold2>
<SqlTimeoutSeconds>15</SqlTimeoutSeconds>
<TimeoutSeconds>300</TimeoutSeconds>
<IntervalSeconds>600</IntervalSeconds>
<SyncTime/>
</Configuration>
</UnitMonitor>