Tutorial: configure alerts for an availability group
In this tutorial you configure the alerts of the ag-ventas availability group of Ciguapa Inc. so they reflect the business's recovery point objective (RPO), reach the right Slack channel, and stay quiet during planned work. You finish by proving it with a planned failover.
You will learn how to:
- Turn an RPO into thresholds set once for a whole environment.
- Route alerts to Slack with a minimum severity.
- Use a maintenance window so a planned failover does not page anyone.
Before you begin
- The group is monitored. If not, follow Quickstart: add an availability group.
- You are Entity admin on Ciguapa Inc., and Slack is configured on the Excubius server.
- A database administrator can run a planned manual failover of
ag-ventasduring the test.
1. Turn the RPO into thresholds
Ciguapa Inc. accepts losing at most 5 minutes of data. The check sqlserver_ag.secondary_lag estimates, per database and secondary, how many seconds of data a failover would lose. Its catalog baseline is a warning above 60 seconds and critical above 300 seconds, which already matches a 5-minute RPO.
The redo queue tells you how long a failover would take to recover. For Ciguapa's busy sales database, warn earlier than the baseline:
- Open Settings › Entities and choose Ciguapa Inc. › Production.
- Open Threshold defaults and select Set a default for a check.
- Choose Database synchronization, queues and data loss (
sqlserver_ag.database_sync). - Select Set here and enter warning
> 25600KB for5mand critical> 256000KB for5m. - Select Save.
Every availability group in Production, present and future, now uses these values. The check page of each group shows from Production next to them.
Set the value on the environment, not on the group. When Ciguapa adds a second group next year, it inherits the right thresholds with no extra step.
2. Send the alerts to Slack
- Open Settings › Notifications and choose Ciguapa Inc. in the entity picker.
- Select Add Slack channel. Enter the name Ciguapa alerts, the Slack channel
#ciguapa-alerts, Minimum Warning and Message language Español if the team reads Spanish. - Select Test. A test message appears in the channel. If Slack refuses it, invite the bot to the channel and test again.
Alerts from everything under Ciguapa Inc. now go to that channel.
3. Open a maintenance window for the test
A failover always raises a critical alert, because every role change needs an explanation. For a planned test, open a window first so nobody is paged:
- Open Settings › Maintenance windows and choose Ciguapa Inc. › Production.
- Select Start maintenance now, 30 minutes, reason Planned failover test of ag-ventas.
- Choose Some resources and pick
ag-ventas. Its replicas and databases are covered with it.
4. Fail over and watch
- Ask the database administrator to run a planned manual failover of
ag-ventastosql-ventas-02. - On the Overview, the group shows Maintenance and the primary changes within about 30 seconds.
- In the Alert inbox, filter Status: All. An alert Role change / failover detected is open, marked opened during maintenance. No Slack message was sent.
- Select the alert, read the timeline, and select Resolve with the note Planned test.
5. Close the window
Select End now on the window. If any alert were still open, it would be announced in #ciguapa-alerts now, as if it had just opened. Since you resolved it, nothing is sent.
Clean up
- Fail back to
sql-ventas-01the same way, inside a new window. - Keep the thresholds and the channel; they are now the group's configuration.