Collecting additional metrics using Guest OS diagnostics
Microsoft Azure provides a set of standard host-level metrics. Guest OS metrics are not available by default. You can use guest-level monitoring to collect metrics of your guest virtual machines. The metrics are useful for investigating the capacity-related issues that might occur in your Azure environment. When you run the Microsoft Azure API ETL, these metrics are imported into the TrueSight Capacity Optimization database.
- Configure and run the ETL. For more information, see Microsoft Azure - Azure API Extractor.
- Verify that the metrics are displayed in the Workspace.
To enable data collection at a 15-minute resolution for Linux virtual machines
After you enable the guest-level monitoring for a new or an existing virtual machine, perform the following steps:
- Log in to the Azure portal.
- Select Monitoring > Diagnostic settings.
The Diagnostic settings page is displayed.
- On the Metrics tab, in the Metric Aggregation Intervals field, enter PT15M, as shown in the following image:
Performance metrics for Linux virtual machines
The following table lists the metrics that are available when the guest-level monitoring option is enabled in Azure for Linux virtual machines:
To enable data collection at a 15-minute resolution for Windows virtual machine
After you enable the guest-level monitoring for a new or an existing virtual machine, perform the following steps in Azure Cloud Shell:
Set the following variables:
my_resource_group={Resource group name containing your Windows VM and the storage account}
my_windows_vm={Your Azure Windows VM name}
my_diagnostic_storage_account={Your Azure storage account for storing VM diagnostic data}Run the following command to get the resource ID of the virtual machine:
my_vm_resource_id=$(az vm show -g $my_resource_group -n $my_windows_vm --query "id" -o tsv)Run the following command to get the default configurations of the diagnostic settings:
az vm diagnostics get-default-config --is-windows-os \
| sed "s#__DIAGNOSTIC_STORAGE_ACCOUNT__#$my_diagnostic_storage_account#g" \
| sed "s#__VM_OR_VMSS_RESOURCE_ID__#$my_vm_resource_id#g"An output is generated with two code blocks for protected settings and default configurations respectively, as shown in the following example. Make sure that the values in the StorageAccount and resourceId fields match the values you set in steps 1 and 2.
- From the output, copy the second code block for default configurations and paste it into a JSON file, for example, default_config.json.
Add the 15-minute resolution setting to the Metric Aggregation Interval field, as shown in the following example:
"MetricAggregation": [
{
"scheduledTransferPeriod": "PT1H"
},
{
"scheduledTransferPeriod": "PT15M"
},
{
"scheduledTransferPeriod": "PT1M"
}
]Run the following commands to acquire storage SaaS token and set the values of the protected settings:
storage_sastoken=$(az storage account generate-sas \
--account-name $my_diagnostic_storage_account --expiry 2037-12-31T23:59:00Z \
--permissions acuw --resource-types co --services bt --https-only --output tsv)
protected_settings="{'storageAccountName': '$my_diagnostic_storage_account', \
'storageAccountSasToken': '$storage_sastoken'}"Run the following command to apply the changes:
az vm diagnostics set --settings default_config.json \
--protected-settings "$protected_settings" \
--resource-group $my_resource_group --vm-name $my_windows_vm- To verify the changes, on your Windows virtual machine page, navigate to the Metrics tab, and perform the following steps:
- In Metric Namespace, select Guest (classic).
- In Time granularity, select 15 minutes.
Performance metrics for Windows virtual machines
The following tables list the metrics that are available when the guest-level monitoring option is enabled in Azure for Windows virtual machines:
1 - Indicates that the metrics are available in TrueSight Capacity Optimization only when the following steps are performed on your Windows virtual machines.
Steps to create the Template
- Log in to the Azure portal.
In the left pane, select Virtual machines. - A list of your virtual machines is displayed.
- Select the virtual machine for which you want to get the missing additional metrics.
- In the left pane of virtual machine, in the Monitoring category, click Diagnostic settings.
- On the Diagnostics settings page, click Performance counters tab and then select the Custom option.
A list of performance counters appears. - Enter the name of the performance counter, specify the unit, and click Add.
Repeat this step for each performance counter and then click Save. - From the list of Azure services, click Resource groups.
- In the left pane, from the list of resource groups, select the resource group in which your virtual machine resides.
- In the resource group settings, select Deployments. Select the latest deployment from the list.
- From the Overview page, in the Deployment details expander, ensure that the name of the virtual machine is correct. This VM must be the VM for which you have added the performance counters.
- In the left pane, select Template > Add to library (preview).
- Add a name and description for the template, and save it.
- Log in to the Azure portal.
Steps to Deploy the template on a virtual machine
- Log in to the Azure portal.
- From the list of Azure services, select Templates, and edit the template that you have created in the earlier section.
- On the Edit Template page, click Next:ARM Template and update the fields and save the template:
- "name": "<vm_name>/Microsoft.Insights.VMDiagnostisSettings"
- "resourceId": '/subscriptions/<subscription_id>/resourceGroups/resourcegroup/providers/Microsoft.Compute/virtualMachines/<vm_name>"
- From the Template preview page, click Deploy. The Custom deployment page appears.
- Maintain the default fields, choose the Resource group, agree to the terms and conditions, and click Purchase. Note that the Purchase
The deployment to the resource group begins. The metrics are available on the virtual machines after the deployment is complete.
2 - Indicates metrics that are set at level 4. These metrics are imported only when the collection level of the ETL is set to ‘Extended’.