Azure Tips ‘n Tricks – Azure VM monitoring
Azure Monitoring
Cloud applications are complex with many moving parts. Monitoring provides data to ensure that your application stays up and running in a healthy state. It also helps you to stave off potential problems or troubleshoot past ones. In addition, you can use monitoring data to gain deep insights about your application. That knowledge can help you to improve application performance or maintainability, or automate actions that would otherwise require manual intervention.
The following diagram shows a conceptual view of Azure monitoring, including the type of logs you can collect and what you can do with that data:
Enable Azure diagnostics in a virtual machine with the Azure portal
Enabling monitoring on Azure VMs is fairly easy:
- In the Azure portal, navigate to the virtual machine, select Optional Configuration, then Diagnostics and set Status to On.Upon completion, the VM has the Azure Diagnostics extension installed and running.
This extension is responsible for collecting your diagnostics data. - Enable monitoring and configure event logging on an existing VM. You can enable diagnostics at the VM level.
To enable diagnostics and then configure event logging, perform the following steps:- Select the VM.
- Click Monitoring.
- Click Diagnostics Settings.
- Set the Status to ON.
- Configure the storage account you want to use.
- Select each diagnostics log that you want to collect.
- Click OK.
As soon as this had been set, all the selected data will be captured and stored in the storage account.
Monitoring Use cases:
Visualize
Visualizing your monitoring data in graphics and charts helps you find trends far more quickly than looking through the data itself.
A few visualization methods include:
- Use the Azure portal
- Route data to Azure Application Insights
- Route data to Microsoft PowerBI
- Route the data to a third-party visualization tool using either live streaming or by having the tool read from an archive in Azure storage
Archive
Monitoring data is typically written to Azure storage and kept there until you delete it.
A few ways to use this data:
- Once written, you can have other tools within or outside of Azure read it and process it.
- You download the data locally for a local archive or change your retention policy in the cloud to keep data for extended periods of time.
- You leave the data in Azure storage indefinitely, though you have to pay for Azure storage based on the amount of data you keep.
Query
You can use the Azure Monitor REST API, cross platform Command-Line Interface (CLI) commands, PowerShell cmdlets, or the .NET SDK to access the data in the system or Azure storage+
Examples include:
- Getting data for a custom monitoring application you have written
- Creating custom queries and sending that data to a third-party application.
Route
You can stream monitoring data to other locations in real time.
Examples include:
- Send to Application Insights so you can use the visualization tools there.
- Send to Event Hubs so you can route to third-party tools to perform real-time analysis.
Automate
You can use monitoring data to trigger alerts or even whole processes. Examples include:
- Use data to autoscale compute instances up or down based on application load.
- Send emails when a metric crosses a predetermined threshold.
- Call a web URL (webhook) to execute an action in a system outside of Azure
- Start a runbook in Azure automation to perform any variety of tasks
Caveat
While this is pretty amazing what you can achieve with this, there is 1 caveat that you need to be aware of ..
If you have IIS applications on Azure VM’s and these applications store custom logs that need to be available for consulting on the VM itself, make sure you store these outside of the default IIS log path:
The reason herefor is that the Azure IIS monitoring moves ALL files it finds in this location to the diagnostic storage account!
While you are able to use tools to read out Azure Storage accounts (Azure Storage Explorer), this might not be a wanted situation.
Big thanks to Paul De Jong for pointing this out to me!