Microsoft Azure Monitor
Follow the steps below to enable the memory utilization metric in Azure Monitor for Compute Software. Follow the "Linux" section for Linux based OSes and the "Windows" section for Windows OSes.
Linux
The Linux steps will walk you through installing and enabling the Telegraf agent to report memory utilization to Azure Monitor.
Enable Managed Identity
A system-assigned managed identity enables Azure resources to authenticate to cloud services without storing credentials in code. Telegraf will use the managed identity to send metrics to Azure Monitor.
- Navigate to "Virtual machines" in the Azure console.
- In the "Virtual machines" page, select the desired virtual machine.
- In the left panel, click Identity. Under Status, select On. Click Save.
Install Telegraf
- Follow the Telegraf installation steps for your OS. Prior to starting the agent, generate a new Telegraf config file.
- Generate a new Telegraf config file for reporting cpu and memory to Azure Monitor.
telegraf --input-filter cpu:mem --output-filter azure_monitor config > azm-telegraf.conf sudo cp azm-telegraf.conf /etc/telegraf/telegraf.conf
- Restart the agent.
sudo systemctl restart telegraf
Windows
Enable Managed Identity
A system-assigned managed identity enables Azure resources to authenticate to cloud services without storing credentials in code. The Azure Diagnostics agent will use the managed identity to send metrics to Azure Monitor.
- Navigate to "Virtual machines" in the Azure console.
- In the "Virtual machines" page, select the desired virtual machine.
- In the left panel, click Identity. Under Status, select On. Click Save.
- Under Permissions, click Azure role assignments.
- Click Add Role Assignment.
Select "Subscription" for Scope and pick your Subscription.
For Role, select "Monitoring Metrics Publisher".
Click Save.
Send Diagnostic Data to Azure Monitor
- Navigate to "Virtual machines" in the Azure console.
- In the "Virtual machines" page, select the desired virtual machine.
- In the left panel, under Monitoring, click Diagnostic Settings.
- In the Overview tab, under the Diagnostics storage account drop-down, select or create a diagnostics storage account.
- Click Enable guest-level monitoring. Click Save.
- In the Sinks tab, under Send diagnostic data to Azure Monitor, select Enabled. Click Save.
Troubleshooting
Required Metrics Namespace
Ensure the metrics namespace has been enabled, by following these steps:
- In the Azure portal search, type “virtual machines”.
- Under Monitoring, click Metrics
- In the Metrics panel, click the Metric Namespace dropdown.
- Ensure the required metric namespaces are reporting values.
Run the below Azure CLI command.
az monitor metrics list-namespaces --resource [resource URI]
For Linux resources, ensure the Telegraf/mem
namespace is included under properties.metricNamespaceName
.
{
"classification": "Custom",
"id": "/subscriptions/{subscriptionID}/resourcegroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{resourceName}/providers/microsoft.insights/metricNamespaces/Telegraf-mem",
"name": "Telegraf-mem",
"properties": {
"metricNamespaceName": "Telegraf/mem"
},
"resourceGroup": "<your resource group>",
"type": "Microsoft.Insights/metricNamespaces"
}
For Windows resources, ensure the Azure.VM.Windows.GuestMetrics
namespace is included under properties.metricNamespaceName
.
{
"classification": "Custom",
"id": "/subscriptions/{subscriptionID}/resourcegroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{resourceName}/providers/microsoft.insights/metricNamespaces/Azure.VM.Windows.GuestMetrics",
"name": "Azure.VM.Windows.GuestMetrics",
"properties": {
"metricNamespaceName": "Azure.VM.Windows.GuestMetrics"
},
"resourceGroup": "windows-with-mem_group",
"type": "Microsoft.Insights/metricNamespaces"
}