Azure Monitor starts collecting data from Azure virtual machines the moment that they’re created. In this article, we will see how Azure Monitor can be helpful for monitoring the virtual machines.
You’ll then enable Azure Monitor for VMs for your VM which will enable agents on the VM to collect and analyze data from the guest operating system including processes and their dependencies.
Create Virtual Machine
The next steps assumes that you already have a virtual machine (either windows or linux VM). If you don’t have a virtual machine already, then below articles provide step by step information. For this demo, we will use linux virtual machine.
Virtual Machine Overview Panel
Once virtual machine is created and it is running, as stated earlier, Azure Monitor already starts capturing the metrics. If you login to Azure Portal and navigate to the running virtual machine, it will show overview panel.
This overview panel has four tabs –
Tutorials. Select Monitoring tab and you would be able to see a lot of details, like average CPU usage percentage, Network usage, Disk Operations, etc.
There are also options to view Activity Log which will show all the activities performed on the virtual machine resource. There is also a menu Metrics in left side navigation, which shows additional metrics in the form of graphical representation.
Important point to note is all these metrics are from the host machine, i.e. the machine which is hosting this virtual machine. In next section, we are going to see how to get insights from the Guest OS.
Azure Monitor for VMs
You need an agent and some configuration to collect and analyze monitoring data from the guest operating system and its workloads. Azure Monitor for VMs installs these agents and provides additional powerful features for monitoring your virtual machines.
Login to Azure Portal and navigate to the concerned virtual machine. Either click Go to Insights from the tile in the Overview page, or click on Insights from the Monitoring menu. Below panel will open:
If the virtual machine is not already attached to a log analytics workspace, then the next screen will ask to select a
Log Analytics Workspace and the valid subscription name. Make sure that
Log Analytics workspace should be in the same region as the virtual machine.
There is an option to either select an existing workspace or create a new one. For this demo, I selected the new workspace.
This will start onboarding of the virtual machine. This onboarding will take few minutes to complete the installation of agent and installation of extensions.
Note that you may not see the above step and you may see an error instead asking you to upgrade the agent. Refer this documentation for more details to resolve the error.
Log Analytics Advanced Settings
Now, login to Azure Portal, and navigate to the Log Analytics workspace selected for insights. When the workspace opens, select Advanced Settings from the left side navigation.
On the Advanced Settings panel, the options are visually distributed in 3 columns.
Select Data option from first column.
In second column, select option based on the Guest OS:
- For Windows VM, select Windows Event Logs in second column
- For Linux VM, select Syslog in second column
For third column, you need to select the source of logs:
- For Windows VM, type System and then click on plus (+) sign, then a table would be visible with some check-boxes. Select two check boxes, Error and Warning.
- For Linux VM, type Syslog and then click on plus (+) sign. This would make a table visible with some check boxes. Optionally, deselect the Info, Notice and Debug.
Once these values are selected, then click on Save button.
For measuring performance of our Linux VM, select Data -> Linux Performance Counters and then select Apply below configurations check box.
Then hit Save button.
Viewing the collected data
In Azure Portal, navigate to the virtual machine. Next, select the Insights option from left side navigation. On the new panel, there will be two tabs – Performance and Map. Under Performance tab, you can see graphical representation of metrics.
Select Map to open the maps feature which shows the processes running on the virtual machine and their dependencies. Select Properties to open the property pane if it isn’t already open.
Select your virtual machine again and then select Alerts.
I hope you enjoyed this article. Let me know your thoughts.