SQL Agent Job Monitoring with Custom Alerting
By Tom Nonmacher
SQL Agent Job Monitoring is a vital part of maintaining an efficient and smooth-running database system. With the ability to monitor the performance of your SQL Agent Jobs, you can identify and remedy potential issues before they become problematic. In this blog post, we will explore how to set up custom alerting for SQL Agent Job Monitoring using technologies from SQL Server 2012, SQL Server 2014, MySQL 5.6, DB2 10.5, and Azure SQL.
The first step in setting up custom alerting for SQL Agent Job Monitoring is to create a job that will monitor your SQL Agent Jobs. In SQL Server 2012 and 2014, this can be done using the SQL Server Agent. You can configure the job to execute a script that checks the status of all SQL Agent Jobs and sends an alert if any jobs are failing.
BEGIN TRANSACTION
CREATE JOB [MonitorSQLAgentJobs]
@description=N'Monitor SQL Agent Jobs',
@enabled=1,
@notify_level_eventlog=2,
@notify_level_email=2,
@notify_level_netsend=2,
@notify_level_page=2,
@delete_level=0,
@category_name=N'[Uncategorized (Local)]',
@owner_login_name=N'sa',
@notify_email_operator_name=N'Alerts'
COMMIT
For MySQL 5.6, we can use the Event Scheduler to create a similar job. The event will regularly execute a script that checks the status of all jobs and sends an alert if any jobs are failing.
CREATE EVENT MonitorJobs
ON SCHEDULE EVERY 1 MINUTE
DO
BEGIN
DECLARE failed_jobs INT;
SELECT COUNT(*) INTO failed_jobs
FROM information_schema.events
WHERE status = 'FAILED';
IF failed_jobs > 0 THEN
CALL send_alert(failed_jobs);
END IF;
END
For DB2 10.5, we can use the ADMIN_TASK_ADD procedure to create a task that checks the status of all jobs and sends an alert if any jobs are failing.
CALL ADMIN_TASK_ADD ('MonitorJobs',
'CALL CHECK_JOBS()',
'* * * * *',
'',
'',
'',
'',
'')
Azure SQL does not have a built-in job scheduler like SQL Server Agent or MySQL Event Scheduler. However, we can use Azure Automation to create a runbook that checks the status of all jobs and sends an alert if any jobs are failing. The script can be written in PowerShell and can leverage the AzureRM.Sql module to interact with Azure SQL.
As a part of the monitoring process, you may want to set up alerts for specific events or conditions. Custom alerts can be set up to notify you when a job fails, when a job takes longer than expected to complete, or when a job hasn't run at its scheduled time. This way, you can be proactive in your approach to managing your SQL Agent Jobs and ensure that your database system is running efficiently and effectively.
In conclusion, SQL Agent Job Monitoring with custom alerting is a powerful tool in maintaining an efficient database system. By creating jobs that check the status of SQL Agent Jobs and send alerts when necessary, you can ensure that potential issues are identified and remedied quickly. Regardless of the database technology you are using, setting up custom alerting for SQL Agent Job Monitoring is a beneficial practice for any database administrator.
Check out the latest articles from all our sites:
- How to Take Advantage of Flash Sales at Grocery Stores [https://www.ethrift.net]
- A brief history of the Galveston Hurricane of 1900 [https://www.galvestonbeachy.com]
- How to Plant and Maintain Chokeberry Bushes [https://www.gardenhomes.org]
- New Query Store Enhancements in SQL Server 2022 [https://www.sqlsupport.org]
- Heat: Why My Laptop Is Cooking My Lap [https://www.SupportMyPC.com]
- The Best Months to Visit South Korea for Cherry Blossoms and Fall Colors [https://www.treasureholidays.com]
Privacy Policy for sqlsupport.org
Last updated: Feb 03, 2026
sqlsupport.org respects your privacy and is committed to protecting any personal information you may provide while using this website.
This Privacy Policy document outlines the types of information that are collected and recorded by sqlsupport.org and how we use it.
Information We Collect
- Internet Protocol (IP) addresses
- Browser type and version
- Pages visited
- Time and date of visits
- Referring URLs
- Device type
Cookies and Web Beacons
sqlsupport.org uses cookies to store information about visitors preferences and to optimize the users experience.
How We Use Your Information
- Operate and maintain our website
- Improve user experience
- Analyze traffic patterns
- Prevent fraudulent activity
Contact
Email: admin@sqlsupport.org