Create a CPU status alert for a SQL Server on Azure

Estimated Time: 30 minutes

You have been hired as a Senior Data Engineer to help automate day to day operations of database administration. This automation is to help ensure that the databases for AdventureWorks continue to operate at peak performance as well as provide methods for alerting based on certain criteria.

Note: These exercises may ask you to copy and paste T-SQL code and makes use of existing SQL resources. Please verify that the code has been copied correctly, before executing the code.

Create an alert when a CPU exceeds an average of 80 percent

  1. In the search bar at the top of the Azure portal, type SQL, and select SQL databases. Select the AdventureWorksLT database name listed.

    Screenshot of selecting a SQL database

  2. On the main blade for the AdventureWorksLT database, navigate down to the monitoring section. Select Alerts.

    Screenshot of selecting Alerts on the SQL database Overview page

  3. Select Create alert rule.

    Screenshot of selecting New alert rule

  4. In the Select a signal slide out, select CPU percentage.

    Screenshot of selecting CPU percentage

  5. In the Configure signal slide out, select Static for the Threshold property. Then check that the Operator property is Greater than, the Aggregation type is Average. Then in Threshold value enter a value of 80. Select Done.

    Screenshot of entering 80 and selecting Done

  6. Select the Actions tab.

    Screenshot of selecting the Select action group link

  7. In the Actions tab, select Create action group.

    Screenshot of selecting the Create action group

  8. On the Action Group screen, type emailgroup in the Action group name field, and then select Next: Notifications.

    Screenshot of entering emailgroup and selecting Next: Notifications

  9. On the Notifications tab, enter the following information:

    • Notification type: Email/SMS message/Push/Voice
      • Note: When you select this option, a Email/SMS message/Push/Voice flyout will appear. Check the Email property and type the Azure username you signed in with.
    • Name: DemoLab

    Screenshot of the Create action group page with information added

  10. Select Review + create, then select Create.

    Screenshot of the Create alert rule page selecting the Create alert rule

    Note: Before you select Create, you can also select Test action group (preview) to test the Alert.

  11. An email like this is sent to the email address that you entered, once the rule is created.

    Screenshot of the confirmation email

    With the alert in place, if the CPU usage on average exceeds 80%, an email like this is sent.

    Screenshot of the warning email

Alerts can send you an email or call a web hook when some metric (for example database size or CPU usage) reaches a threshold you define. You’ve just seen how you can easily configure alerts for Azure SQL Databases.