One of the great things about Diagnostic Manager is the ability to create custom alerts.  This is something I believe needs a bit more work, but even in its current state, it is really useful.

The example that we’ll walk through is something that would actually make a great built in alert.  We will create an alert based on the time of our oldest current database backup.

To start off, click on “Administration” in the bottom right hand corner:

Next Click on Custom Counters (there are two spots that you can click on for it):

Now in the menu ribbon, click on Add.

On the first screen of the wizard, click on Next at the bottom.

We are going to base our Custom Counter/Alert on a SQL Query, so choose the 3rd option: Custom SQL Script.

On the next screen we add the SQL Query.

<code>
SELECT ROUND(MAX(DATEDIFF(MINUTE,LastBackUpTaken,GETDATE()))/60.0,2)  
FROM  
( 
SELECT sdb.Name AS DatabaseName
,COALESCE(MAX(bus.backup_finish_date),GETDATE()-100) AS LastBackUpTaken    
FROM master..sysdatabases sdb    
LEFT OUTER JOIN msdb.dbo.backupset bus    
ON bus.database_name = sdb.name    
WHERE sdb.Name NOT IN ('tempdb','model')   
AND bus.type = 'L'   
GROUP BY sdb.Name  
) 
DBList;

*Note the code provided above is different from the screenshot. While proof reading this article, I realized that I forgot include the backup type in the query.

On the next screen we want to leave the Customize Calculation Type set to "Use collected value".  We are doing this because we want to base the alert off the most recent value.  If we had chosen to set it to "Use per second value since last collection" then it would base the alert on the difference between the most recent two results of our query.

On the same screen we also want to leave the Customize Scale Factor at 1.  We are doing this because we've already set our query to return the number of hours since the latest current backup was completed.

If we click on the test button we can run the query on all or some of our monitored instances to ensure it works.  When you are finished testing, click on Done and then Next.

You want to be sure to put a meaningful and descriptive name on the next screen.  This is the name that will appear in the alerts screen.

For my case, I don't have many custom alerts so I keep keep the category set to Custom for all of them.

I setthe description that you see in the screenshot below so that I include the code to find which databases need to be backed up is at my fingertips.

On the next screen, we want to choose the option of "Higher values are worse than lower values" because a higher number means it's been longer since the last backup.

I like to set the informational warning at 24 hours.  At that point it is not a problem, but something I want to be aware of.  The warning is set at 26 hours because it could just be that a backup is running long for some reason.  When we hit 28 hours that means that something is definately not right.

This is the type of counter that I want on every instance no matter it is used for, so I check the bottom check box.

The next screen just tells you that you have completed the wizard and warns you that you still need to link the custom counter to your monitored SQL Instances.

On the next screen you can select whether or not you want to link this new customer counter your monitored SQL Instances right away.

The other way to link the custom counter is to select the counter and choose link from the menu above it.

I won't do any screenshots of the screen where you choose which servers to link because it is a very straight forward screen where you select the SQL Instance from the left side and click on the add button.

At the start of this blog post, I mentioned that there are some change that would be really helpful.  What I meant by that is adding the option to include a second query that would be executed and the results displayed as a "drill in" option for the counter.

You can also easily turn this counter into one for log backups