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.

  1. Navigate to "Virtual machines" in the Azure console.
  2. In the "Virtual machines" page, select the desired virtual machine. Select VM
  3. In the left panel, click Identity. Under Status, select On. Click Save. Configure Identity

Install Telegraf

  1. Follow the Telegraf installation steps for your OS. Prior to starting the agent, generate a new Telegraf config file.
  2. 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
    
  3. 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.

  1. Navigate to "Virtual machines" in the Azure console.
  2. In the "Virtual machines" page, select the desired virtual machine. Select VM
  3. In the left panel, click Identity. Under Status, select On. Click Save. Configure Identity
  4. Under Permissions, click Azure role assignments. Role Assignments
  5. Click Add Role Assignment. Select "Subscription" for Scope and pick your Subscription. For Role, select "Monitoring Metrics Publisher". Click Save. Assign Role

Send Diagnostic Data to Azure Monitor

  1. Navigate to "Virtual machines" in the Azure console.
  2. In the "Virtual machines" page, select the desired virtual machine.
  3. In the left panel, under Monitoring, click Diagnostic Settings.
  4. In the Overview tab, under the Diagnostics storage account drop-down, select or create a diagnostics storage account. Enable Guest Monitoring
  5. Click Enable guest-level monitoring. Click Save.
  6. In the Sinks tab, under Send diagnostic data to Azure Monitor, select Enabled. Click Save. Send diagnostic data to Azure Monitor

Troubleshooting

Required Metrics Namespace

Ensure the metrics namespace has been enabled, by following these steps:

  1. In the Azure portal search, type “virtual machines”.
  2. Under Monitoring, click Metrics
  3. In the Metrics panel, click the Metric Namespace dropdown.
  4. 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"
}