Configuring diagnostic settings on resources

To enable the diagnostic settings for resources, perform the following steps:

  1. Navigate to the VM you created previously.
  2. Make sure that the VM is running, and in the left-hand menu, under Monitoring, select Diagnostic settings.
  3. The Diagnostic Settings blade will open up. You will need to select a storage account where the metrics can be stored; if you don’t have a storage account, you can create a new one.
  4. Click on the Enable guest-level monitoring button to update the diagnostic settings for the VM.
  5. When the settings are updated, you can go to Metrics in the Monitoring section for your VM on the left menu.
  6. Change the metric namespace to Guest (classic), and note that you have new metrics available from the Metrics dropdown after enabling diagnostic logging. You can analyze them in the same way that we did earlier in this chapter.

Now that you have configured diagnostic settings, we will explore triggering an alert from your VM to see how this works.

Triggering an alert

In this exercise, we will explore a method to push the CPU usage up high on our VM and then trigger the alert we configured previously:

  1. Log on to your Monitor VM using remote desktop protocol (RDP).
  2. Disable IE Enhanced Security Configuration. From Server Manager, you can click Local Server on the left-hand menu and then click On to change the setting:

Figure 20.27 – IE Enhanced Security Configuration

  1. Download FurMark: https://www.guru3d.com/files-get/furmark-1-8-2,5.html.
  2. Install FurMark and launch it once complete.
  3. Click CPU burner:

Figure 20.28 – FurMark

  1. Click Start to start running the tool and stress-testing the CPU on the VM:

Figure 20.29 – Running FurMark

  1. If you open Task Manager, note that the CPU is now sitting at 100%:

Figure 20.30 – Task Manager

  1. You will need to leave this running for a few minutes for Azure Monitor to register the detected CPU usage changes. Navigate to the dashboard you created earlier and note that the CPU is showing as 99.9%:

Figure 20.31 – Dashboard – showing high CPU usage

  1. Check your email, as an alert should now be present to notify you of the detected issue.

You have successfully created some metric monitors in this section, explored how to add them to a dashboard, created an alert to be triggered should a metric anomaly be detected, and finally, explored what happens when an alert is triggered. You should now feel comfortable configuring metrics in Azure Monitor.

In the next section, we’re going to look at the Azure Log Analytics service, which is now a part of Azure Monitor as well.