Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk8 min

AlwaysOn Availability Groups and SQL Server Jobs, Part 5: Setting Up Failover Alerts

A production-focused guide to AlwaysOn failover alerts: prerequisites, SSMS and T-SQL setup for messages 1480, 35264, and 35265, validation, job responses, and troubleshooting.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a SQL Server AlwaysOn Availability Group (AG), create SQL Server Agent alerts for message IDs 1480, 35264, and 35265, then test the complete path from SQL Server event to an operator’s inbox. Message 1480 is used for an AG replica-role change; 35264 and 35265 are used for data-movement suspension and resumption. Verify the message text on your SQL Server build, because the historical 2014 guidance has inconsistent labels for the latter two IDs.

This procedure targets SQL Server on Windows with SQL Server Agent and Database Mail. Azure SQL Managed Instance, Linux, and container deployments have different support and logging details; Microsoft documents those differences at SQL Server Agent alerts.

As an Amazon Associate I earn from qualifying purchases.

What these alerts tell you

An AG can move the primary role to another host while applications continue using the same database and listener names. Without notification, operators may not know that a planned or unexpected transition occurred. The alerts below report an event; they do not identify its cause or prove that the application recovered.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Purpose Message ID Suggested alert name Interpretation
Replica role change 1480 AG Role Change Use as a failover or role-transition signal. It does not inherently distinguish planned, automatic, forced, or fault-induced changes.
Data movement suspended 35264 AG Data Movement - Suspended Availability-group data movement stopped. Confirm the event text on the target build.
Data movement resumed 35265 AG Data Movement - Resumed Data movement restarted. This does not mean queues are empty or synchronization is healthy.

The mapping above follows the historical Part 5 guidance, whose original page was published on September 9, 2014 and now redirects after an ITPro Today migration. Check the current text in sys.messages before production deployment: historical article.

How SQL Server Agent decides to send an alert

  1. SQL Server raises an event.
  2. The qualifying event is written to the SQL Server and/or Windows Application log.
  3. SQL Server Agent compares the event with enabled alert definitions.
  4. A matching alert notifies an operator by email and can optionally start a SQL Server Agent job.

Having a row in sys.messages is not enough. Microsoft states that only qualifying messages written to the Windows Application log can trigger these alerts. See sp_add_alert documentation.

Prerequisites and topology decisions

  • The SQL Server Agent service is running on every instance that can host an AG replica.
  • An SQL Server Agent operator exists with a valid email address.
  • Database Mail is configured, tested, and available to the SQL Server Agent mail profile.
  • The Agent is permitted to use that profile.
  • SMTP DNS, firewall, TLS, authentication, and relay rules allow delivery.
  • Your account has permission to create alerts; by default, sysadmin membership is required for sp_add_alert.
  • Equivalent alerts and operators are deployed on every relevant AG host. Agent alerts are instance-level objects and are not replicated with the availability group.

Configure Database Mail under Management > Database Mail, then set the Agent profile under the SQL Server Agent service properties. Send a direct Database Mail test, but treat it as a separate test: successful Database Mail does not prove that Agent can use the profile or notify the operator.

Create the alerts in SQL Server Management Studio

  1. Connect to the SQL Server instance in SQL Server Management Studio.
  2. Expand SQL Server Agent, right-click Alerts, and choose New Alert.
  3. On General, enter a unique name, select SQL Server event alert, and enter one message number: 1480, 35264, or 35265.
  4. On Response, select the operator and E-mail. Choose a response job only when you have designed and tested it for this event.
  5. Save the alert and repeat for the other message IDs.
  6. Repeat the configuration on each AG instance that must report events.

Alert names are unique within an instance and may be up to 128 characters. Microsoft’s field and alert-type details are documented at learn.microsoft.com/en-us/ssms/agent/alerts.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Create the alerts with T-SQL

Run sp_add_alert and sp_add_notification in msdb. The script below creates the three alerts and includes the event description in notifications.

USE msdb;
GO

-- Replace with the exact existing Agent operator name.
DECLARE @OperatorName sysname = N'DBA Operators';

EXEC dbo.sp_add_alert
    @name = N'AG Role Change',
    @message_id = 1480,
    @severity = 0,
    @enabled = 1,
    @delay_between_responses = 0,
    @include_event_description_in = 1;
EXEC dbo.sp_add_notification
    @alert_name = N'AG Role Change',
    @operator_name = @OperatorName,
    @notification_method = 1; -- 1 = e-mail
GO

EXEC dbo.sp_add_alert
    @name = N'AG Data Movement - Suspended',
    @message_id = 35264,
    @severity = 0,
    @enabled = 1,
    @delay_between_responses = 0,
    @include_event_description_in = 1;
EXEC dbo.sp_add_notification
    @alert_name = N'AG Data Movement - Suspended',
    @operator_name = N'DBA Operators',
    @notification_method = 1;
GO

EXEC dbo.sp_add_alert
    @name = N'AG Data Movement - Resumed',
    @message_id = 35265,
    @severity = 0,
    @enabled = 1,
    @delay_between_responses = 0,
    @include_event_description_in = 1;
EXEC dbo.sp_add_notification
    @alert_name = N'AG Data Movement - Resumed',
    @operator_name = N'DBA Operators',
    @notification_method = 1;
GO

Do not blindly rerun this script. sp_add_alert creates an object; it is not an upsert. Query existing alerts in SSMS or msdb first, then skip, alter, or fail clearly when a name already exists. Also validate that the operator exists before deployment.

The notification bitmap is 1 for email, 2 for pager, and 4 for net send. Microsoft warns that pager and net send are scheduled for removal, so use email or an external notification system for new designs.

Verify the message IDs on your build

SELECT message_id, severity, language_id, text
FROM sys.messages
WHERE message_id IN (1480, 35264, 35265)
  AND language_id = 1033
ORDER BY message_id;
  • Confirm all three messages exist and record their current text.
  • Check that the corresponding event is written to the Windows Application log.
  • Ensure each alert is enabled and points to the intended operator.
  • Repeat this verification after a major SQL Server upgrade or cumulative update.

Test the complete notification chain

  1. Send a direct Database Mail test and confirm delivery.
  2. Use a harmless test alert to verify SQL Server Agent can notify the operator through its configured profile.
  3. In a test AG or during an approved exercise, perform a controlled role transition or reproduce a data-movement interruption.
  4. Check the SQL Server error log, Windows Application log, SQL Server Agent history, and Database Mail log.
  5. Confirm the email includes the host and instance, event description, and AG or database context where available.
  6. After the role changes, verify delivery from the new primary as well as the former primary.
  7. Check that repeated suspend/resume events do not create an unmanageable alert storm.

A successful Database Mail test alone does not validate the Agent alert path. The event must be logged, matched by an enabled alert, routed to an operator, accepted by SMTP, and delivered to the recipient.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Add severity alerts selectively

The historical article also suggested alerts for severities 17 through 25. These severities can indicate resource or system problems, but workloads differ and false positives are possible. Start only with severities that have an acceptable signal-to-noise ratio.

USE msdb;
GO
EXEC dbo.sp_add_alert
    @name = N'Severity 017',
    @message_id = 0,
    @severity = 17,
    @enabled = 1,
    @delay_between_responses = 60,
    @include_event_description_in = 1;
GO

Repeat for other severities only after reviewing your logs. A severity alert uses @severity; a message-number alert uses @message_id. Do not set both as competing criteria for the same definition. The valid severity range for sp_add_alert is 1 through 25.

You may also need separate controls for I/O and storage failures, replication, deadlocks, long-running transactions, and low disk space. Treat these as environment-specific monitoring decisions, not mandatory AG defaults.

When an alert should start a job

An alert can execute a SQL Server Agent job through @job_id or @job_name. A reasonable use is enabling or disabling a tightly scoped group of jobs after a role transition, a pattern discussed in the wider series at Part 28.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Make the response job:

  • Idempotent: running twice produces the same safe state.
  • Role-aware: it checks the local replica role and intended AG before changing anything.
  • Race-resistant: it tolerates rapid failover and failback.
  • Observable: it logs clear success and failure outcomes.
  • Pre-deployed: the job exists on every instance that may receive the event.

Never assume a role-change alert identifies the reason for a transition. Correlate it with Windows Failover Clustering events, the SQL Server error log, AG DMVs or dashboard, change records, and application telemetry.

Understand the important limits

  • A resumed-data-movement event means movement restarted; it does not prove synchronization state, send and redo queues, listener availability, or application connectivity are healthy.
  • A single message-number alert can match events from multiple AGs or databases on one instance. Use event-description filtering, routing, or an external monitor when topology-specific ownership matters.
  • @event_description_keyword is a literal substring filter; SQL LIKE wildcard patterns are not supported.
  • Multiple instances, related AG events, and external rules can produce duplicate notifications. Use @delay_between_responses carefully so suppression does not hide a real outage.
  • SQL Server Agent alerts do not continuously measure AG health. Add recurring checks for synchronization state, connection state, send/redo queues, listener health, cluster quorum and lease events, backups, and application availability. See the health-check discussion in Part 18.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot by failure point

Agent does not respond

Confirm the SQL Server Agent service is running, the alert is enabled, and the operator notification exists on that instance.

No alert event appears

Inspect the SQL Server error log and Windows Application log. If the event was not logged, SQL Server Agent cannot match it. Verify the message text and ID on the target build.

Alert exists but no email arrives

Check the operator address, Agent mail profile, Database Mail status and log, SMTP authentication, TLS requirements, firewall, relay policy, and spam quarantine.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Only one node sends notifications

Deploy the operator, mail configuration, alerts, and any response jobs on every relevant AG host. These objects are not synchronized by AlwaysOn.

Notifications are duplicated

Identify whether several instances or monitoring systems are reporting the same event. Apply a measured response delay and define which system owns escalation.

Email arrives but the application is unavailable

Continue with listener, DNS, connection-string, cluster, synchronization, and application checks. An event alert is not a service-recovery test.

Built-in alerts versus external monitoring

SQL Server Agent plus Database Mail is included with SQL Server capabilities and is a practical fit for a small number of low-volume emails or a carefully scoped job response. It is a poor fit when you need centralized dashboards, topology-wide correlation, deduplication, on-call escalation, mobile routing, historical analytics, or application-aware recovery validation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

SQL Server-focused products such as Redgate SQL Monitor and SolarWinds SQL Sentry, or Azure-centric operations through Azure Monitor, can provide those capabilities, but add deployment, security, and licensing overhead. They are optional; the three-message workflow does not require a third-party product.

Production-readiness checklist

  • Target platform and SQL Server version are documented.
  • Agent is running on every possible event source.
  • Database Mail, Agent profile, SMTP path, and operator address are tested.
  • Message IDs 1480, 35264, and 35265 and their current text are verified.
  • Alerts are enabled and uniquely named on every relevant instance.
  • Event descriptions are included in notifications.
  • Any response job is role-aware, idempotent, logged, and present on each host.
  • A controlled failover or test event produced an email and an Agent-history entry.
  • Operators know that alerts report transitions, not root cause or complete health.
  • A separate AG and application-health monitoring process is in place.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.