Situatie
To ensure your virtual machines (VMs) in Azure are running correctly, you can review boot diagnostics, performance metrics and manage package updates. In this tutorial, you learn how to:
- Enable boot diagnostics on the VM
- View boot diagnostics
- View host metrics
- Enable diagnostics extension on the VM
- View VM metrics
- Create alerts based on diagnostic metrics
- Manage package updates
- Monitor changes and inventory
- Set up advanced monitoring
Solutie
Create VM
To see diagnostics and metrics in action, you need a VM. First, create a resource group with az group create. The following example creates a resource group named myResourceGroupMonitor in the eastus location.
Azure CLI
az group create –name myResourceGroupMonitor –location eastus
Now create a VM with az vm create. The following example creates a VM named myVM and generates SSH keys if they do not already exist in ~/.ssh/:
Azure CLI
az vm create –resource-group myResourceGroupMonitor –name myVM –image UbuntuLTS –admin-username azureuser –generate-ssh-keys
Enable boot diagnostics
As Linux VMs boot, the boot diagnostic extension captures boot output and stores it in Azure storage. This data can be used to troubleshoot VM boot issues. Boot diagnostics are not automatically enabled when you create a Linux VM using the Azure CLI.
Before enabling boot diagnostics, a storage account needs to be created for storing boot logs. Storage accounts must have a globally unique name, be between 3 and 24 characters, and must contain only numbers and lowercase letters. Create a storage account with the az storage account create command. In this example, a random string is used to create a unique storage account name.
When enabling boot diagnostics, the URI to the blob storage container is needed. The following command queries the storage account to return this URI. The URI value is stored in a variable names bloburi, which is used in the next step.
--storage
value is the blob URI collected in the previous step.When boot diagnostics are enabled, each time you stop and start the VM, information about the boot process is written to a log file. For this example, first deallocate the VM with the az vm deallocate command as follows:
Azure CLI
az vm deallocate –resource-group myResourceGroupMonitor –name myVM
Now start the VM with the az vm start command as follows:
Azure CLI
az vm start –resource-group myResourceGroupMonitor –name myVM
You can get the boot diagnostic data for myVM with the az vm boot-diagnostics get-boot-log command as follows:
Azure CLI
az vm boot-diagnostics get-boot-log –resource-group myResourceGroupMonitor –name myVM
View host metrics
A Linux VM has a dedicated host in Azure that it interacts with. Metrics are automatically collected for the host and can be viewed in the Azure portal as follows:
- In the Azure portal, select Resource Groups, choose myResourceGroupMonitor, and then select myVM in the resource list.
- To see how the host VM is performing, select Metrics on the VM window, then choose any of the [Host] metrics under Available metrics.
Leave A Comment?