Long-running job

This metric returns the longest running instance of the named job in the last hour. By creating multiple custom metrics from this example – one for each job you're interested in – you can specify alert thresholds for each job individually.

Install metric...

Metrics install automatically if you have SQL Monitor installed.

If you are using Redgate’s SQL Server monitoring tool, SQL Monitor, you can instantly install and run this metric on your servers.

SQL Monitor’s Job duration unusual alert is a powerful tool for keeping track of most jobs in your SQL Server environment. It works by comparing the running time of any job instance against the median for that job, and identifying when a variation in the job duration could hint at a performance problem. However, if your environment contains big jobs whose durations vary by several orders of magnitudes, it can be tricky to specify what kind of variation is expected and what would be unusual. For these cases, it is possible to go beyond the functionality of the built-in alert with a custom metric.

This metric returns the longest running instance of the named job in the last hour. In the example, the job of interest is called ‘My_long_running_job’, so you’ll need to replace this with the job in your environment that you want to target.

By creating multiple custom metrics from this example – one for each job you’re interested in – you can specify alert thresholds for each job individually. Alert thresholds are absolute rather than relative values, which may help cover a few scenarios that the built-in alert is not suited for.

Long-running job, 3.7 out of 5 based on 7 ratings

Metric definition

Name

Long-running job: (My_long_running_job)

Description

This metric returns the total duration (in seconds) of the longest running instance of the named job.

The T-SQL query that will collect data

Instances to collect from

Select all

Databases to collect from

msdb

Collection frequency

3600

Use collected or calculated values

Leave the Use a calculated rate of change between collections check box unchecked

Metric collection

Enabled

Alert definition

Alert name

Long-running job: (My_long_running_job)

Description

This alert is raised when the named job has been running for longer than the thresholds specified.

Raise an alert when the metric value goes

Above the defined threshholds

Default threshold values

High:120
Medium:60
Low:30

Raise an alert when the threshold is passed for

1 collection

Alert is

Enabled