The Wayback Machine - https://web.archive.org/web/20241006113749/https://www.geeksforgeeks.org/microsoft-azure-cpu-and-memory-utilization-of-azure-vms-in-a-single-table-chart/
Open In App

Microsoft Azure – CPU and Memory Utilization of Azure VMs in a Single Table Chart

Last Updated : 30 Mar, 2023
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

In this article, you will see that how you can analyze your azure virtual machine’s performance of both CPU Utilization and Memory Utilization at once using azure log queries. These KQL queries will help you to understand all the Azure VMs Performance in the form of a table chart and this will also allow you to export the data in the CSV file. 

With this data, you can easily analyze, which servers need to be resized for scaling up (increasing the size) or scaling down (decreasing the size).

Advantages of using these KQL Queries: 

  • You can analyze the VMs in Seconds.
  • Easy to filter the VMs
  • Easy to filter log data by using the conditions.
  • Easy to Analyse the performance between time range (Example like 7 Days, 15 Days, 2 Months, 2 Hours, 12 Hours,…etc)
  • Allows us to Export the data in CSV for future reference for past performance.

Implementation:

Step 1: Login to Azure Portal.

Step 2: Go to Log Analytics Workspace >> Navigate to General Section from left menu >> Select Logs

Paste the below following KQL Query to get the Consolidated CPU and Memory Utilization in a Single Table Chart

VM CPU Utilization and MEMORY Utilization – across all the computers by OS Type equals “Windows/Linux” from the select scope

Perf
| where ObjectName == "Processor" and CounterName == "% Processor Time" and InstanceName == "_Total"
| where Computer in ((Heartbeat | where OSType == "Linux" or OSType == "Windows" | distinct Computer))
| summarize MIN_CPU = min(CounterValue), AVG_CPU = avg(CounterValue), MAX_CPU = max(CounterValue) by Computer
| join 
( 
Perf 
| where ObjectName == "Memory"
| where CounterName == "% Used Memory" or CounterName == "% Committed Bytes In Use"
| summarize MIN_MEM = min(CounterValue), AVG_MEM = avg(CounterValue), MAX_MEM = max(CounterValue) by Computer
) on Computer
| project Computer, MIN_CPU, AVG_CPU, MAX_CPU, MIN_MEM, AVG_MEM, MAX_MEM

Output:

Note: You can download the table data in the form of CSV by clicking on Export 

Example 1: To filter the solution based on Average CPU Utilization greater than 50%

Perf
| where ObjectName == "Processor" and CounterName == "% Processor Time" and InstanceName == "_Total"
| where Computer in ((Heartbeat | where OSType == "Linux" or OSType == "Windows" | distinct Computer))
| summarize MIN_CPU = min(CounterValue), AVG_CPU = avg(CounterValue), MAX_CPU = max(CounterValue) by Computer
| join 
( 
Perf 
| where ObjectName == "Memory"
| where CounterName == "% Used Memory" or CounterName == "% Committed Bytes In Use"
| summarize MIN_MEM = min(CounterValue), AVG_MEM = avg(CounterValue), MAX_MEM = max(CounterValue) by Computer
) on Computer
| project Computer, MIN_CPU, AVG_CPU, MAX_CPU, MIN_MEM, AVG_MEM, MAX_MEM
| where AVG_CPU > 50

Output:

Example 2:  To filter the solution based on Average CPU Utilization greater than 50% and Average Memory Utilization greater than 50 %. While we are using and in the query, the condition should satisfy both the conditions.

Perf
| where ObjectName == "Processor" and CounterName == "% Processor Time" and InstanceName == "_Total"
| where Computer in ((Heartbeat | where OSType == "Linux" or OSType == "Windows" | distinct Computer))
| summarize MIN_CPU = min(CounterValue), AVG_CPU = avg(CounterValue), MAX_CPU = max(CounterValue) by Computer
| join 
( 
Perf 
| where ObjectName == "Memory"
| where CounterName == "% Used Memory" or CounterName == "% Committed Bytes In Use"
| summarize MIN_MEM = min(CounterValue), AVG_MEM = avg(CounterValue), MAX_MEM = max(CounterValue) by Computer
) on Computer
| project Computer, MIN_CPU, AVG_CPU, MAX_CPU, MIN_MEM, AVG_MEM, MAX_MEM
| where AVG_CPU > 50 and AVG_MEM > 50

Output:


Previous Article
Next Article

Similar Reads

Microsoft Azure - Get CPU Utilization Data of a Azure VM in Azure Portal
Azure Virtual Machines (VM) is one of several types of on-demand, scalable computing resources that Azure offers. In this article, we will look into the process of getting the CPU Utilization data of an Azure VM in Azure Portal. Implementation: Follow the steps to get the CPU Utilization of an Azure VM in Azure Portal: Step 1: Log in to your Azure
2 min read
Microsoft Azure - Track CPU Utilization of a Azure Virtual Machines using KQL Log Query
In this article, we will look into the process of finding the Minimum, Average, and Maximum CPU Utilization of all Azure Virtual Machines using KQL Log Query. Here the Perf KQL Counter Operator is used to find Azure Virtual Machines performance from collected data logs. Implementation: Follow the below steps to Run the Log Queries. Step 1: Log in t
4 min read
Microsoft Azure - Tracking Memory Utilization of Azure VM using KQL Log Query
In this article, we will look into the process of finding the Minimum, Average, and Maximum Memory Utilization of all Azure Virtual Machines using KQL Log Query. Here we are Perf KQL Counter Operator which is used to find Azure Virtual Machines performance from collected data logs. Implementation: Follow the below steps to Run the Log Queries. Step
4 min read
Microsoft Azure - Azure CLI Commands to Manage Azure VMs
Azure Command-line interface is used to manage or to create Azure resources. By using the simple AZ CLI command we can manage Azure VM quickly and at a Scale. Let's get started by using a few important Azure CLI commands to manage Azure Virtual Machines. 1. Start a Specific Stopped VM in a Select Resource Group Use the below command to start a spec
2 min read
Microsoft Azure - Manage Azure VMs using Azure PowerShell Commands
Here we are using Azure PS Commands to manage azure resources from Azure Cloud Shell or by using Windows PowerShell. By using the simple AZ PS command we can manage Azure VM Quicks without any efforts of navigating in Azure Portal and at Scale. Let's get started by using the major Azure PS commands to manage Azure Virtual Machine. 1. Start a Specif
2 min read
How to Opimize kubernetes Pod CPU And Memory Utilization?
Before we dive into boosting your Kubernetes pod performance, let's take a moment to understand the key players in this orchestration symphony. In the world of Kubernetes, pods are used to run containers, which are the smallest units of computing in Kubernetes. Table of Content Why to optimize Kubernetes Pod CPU and Memory Utilization?How to check
12 min read
Microsoft Azure - Pre-built Azure VMs
In this article, we will learn how to get started with Prebuilt Azure Virtual Machines ready for containers. If you wanted to get started with Docker, and you're thinking if there were some VMs that had already been set up with Docker and some images for you to try out, then you should definitely check out the VMs that are available inside the Azur
2 min read
Microsoft Azure - Check for Apache Log4J Vulnerability in Azure VMs
In this article, we'll be finding the Apache Log4J Application is Installed in Azure Servers or Not by using Azure Portal. As logging to servers is not possible at a time to find Log4J We'll use KQL Query to find it. With the help of KQL Query, we will be finding the Detecting Log4j Installed Servers by using the Azure Monitor service in Azure Port
2 min read
Microsoft Azure - Create SHH Key to Manage Azure Linux VMs
Creating an SSH key resource allows you to manage and use public keys stored in Azure with Linux virtual machines. Here In this article, we will be creating an SSH Key to manage Azure Linux Virtual Machines in Azure by using a public key. Let's get started by creating a one in Azure. Create SHH Key in Azure: Follow the steps to create an SSH key in
2 min read
Microsoft Azure - VMs Patch Update Summary by Installation Status
Here we will be using the KQL Query to find the Status of Patch Updates by Installation Status. Use Azure Log Analytics Workspace or Azure Workbook to run the queries in this article. KQL Query 1: Use the below log analytics log query to get the details of resources where Installation Status is Succeeded. UpdateRunProgress | summarize arg_max(TimeG
2 min read
Scaling Azure VMs: Vertical And Horizontal Strategies
As someone who has been working with Azure for a few years now, I can attest to the importance of having a cloud infrastructure that can adapt to changing workloads and demands. One of the key features that has really impressed me about Azure is its ability to scale virtual machines (VMs) using two main strategies: vertical scaling and horizontal s
11 min read
Backup and Disaster Recovery Strategies for Azure VMs
Azure Virtual Machines (VMs) are an important service in Microsoft's Azure cloud platform. They remove the requirement for physical hardware by allowing users to create, deploy, and customize virtual machines in the cloud. With support for various operating systems and seamless integration with other Azure services, Azure VMs provide a flexible fou
9 min read
Configuring Network Settings for Azure VMs
Microsoft Azure virtual machines (VMs) provide scalable on-demand computing resources. Configuring the network settings of these virtual machines is important to ensure they communicate effectively and securely within your infrastructure. This article walks you through the basics and step-by-step procedures for setting up a network and provides exa
2 min read
Setting Up a VPN Gateway for Azure VMs
Azure VPN Gateway is a service that companies can use to set up remote access for their clients or representatives to safely give them the option to work from home or anywhere without risking their security frameworks to the public web. Overview of VPN Gateway and Its Benefits for Azure VMsAzure VPN Gateway acts as a bridge between your virtual mac
5 min read
Microsoft Azure - Get Azure VM Properties using Azure PowerShell
The purpose of using the Azure PowerShell Commands is to quickly analyze the overall properties of VM/VMs at once the filtering the with select and where conditions. To find the properties of an Azure VM, you can perform the following commands in Azure Cloud Shell to get the details. Command: Get-AzVM Output: 1. Get all properties of an Azure Virtu
2 min read
Microsoft Azure - RDP to Azure Virtual Machines using Azure Bastion
In this article, we will learn how to do RDP(Remote Desktop Protocol) / SSH(Secure Shell) Connection to an Azure VM using Azure Bastion. First, let's discuss Azure Bastion. The Azure Bastion service is a fully platform-managed PaaS service that you provision inside your virtual network. It provides secure and seamless RDP/SSH connectivity to your v
3 min read
Microsoft Azure - Configure Azure SQL with Azure CLI
In this article, we're going to take a closer look at how you can configure something like connectivity using the Azure CLI. What we have here is we are in Azure Data Studio and similar to the SQL notebook we are actually using a PowerShell notebook. That just means all our code cells are going to run PowerShell and we are just connecting to localh
4 min read
Microsoft Azure - Archive Azure VM to Azure Storage Account
In this article, we will be implementing a solution to archive a select azure VM snapshot to a select storage account for archiving using azure cloud shell. For implementation, we will be using Azure CLI commands. Prerequisite:VM SnapshotA storage account is neededUser needs "Storage Blob Contributor Data" IAM Role Access on Archiving Storage Accou
2 min read
Microsoft Azure - Check Status of Azure VM using Azure PowerShell
The following Azure PowerShell command helps you to find the Azure VM Config and properties details of Os Name, Os Version, Hyper V Generation, Disks properties, Extensions properties of Type Handler Version, Status and Message, VM Agents properties of Type Handler Version, Status and Message and also VM Power Status Codes, Messages, Plugins, Time
3 min read
Microsoft Azure - Azure VM Disk Space in Percentage using Azure KQL
Here we'll be using the Azure Insights Metric Query to find the free disk space in percentage using KQL. The purpose of this query is to find disk drive free space of all the Azure VMs without logging into every server. You can Run the following KQL log Queries in Azure Monitor or Azure VM Logs or Log Analytics Workspace. Note: VM Insights Agent sh
1 min read
Microsoft Azure - Enable Azure Monitor VM Insights Agent For Azure VM
Azure Monitor VM Insights Agent enables you to get more visibility into the health and performance of your Azure VM. Here we'll see how we can enable Azure Monitor VM Insights to monitor the health, performance, and dependencies of azure virtual machines. Implementation: Follow the below steps to enable Azure Monitor VM insights agents for an Azure
2 min read
Microsoft Azure - Query Azure Storage Logs in Azure Monitor Log Analytics
Pre-requisite:- Azure Log Analytics is a tool offered by Azure, which is used to edit and run log queries against data in the Azure Monitor Logs store and helps interactively analyze their results. One can easily use Log Analytics queries to retrieve records that match particular criteria, identify trends, analyze patterns, and provide various insi
5 min read
Microsoft Azure - Install Azure Command Line Interface (Azure CLI)
Azure CLI is a very powerful tool that can be used to automate tasks, create, update, manage or delete azure resources or to troubleshoot problems with az module cmdlets. By installing az modules on your system or on your development system you and your development team can easily create, update or manage Azure AD and Azure resources such as manage
4 min read
Microsoft Azure- Backing Up, Restoring, and Cloning Microsoft Azure App Services
Microsoft is well known for developing relevant software which are using in today's time of technology to conquer the demand of users and developers to build up applications. In sequence of it Microsoft introduces Azure well known as Microsoft Azure to make quality applications. In this article, we will discuss Backing up, restoring and cloning Mic
8 min read
Microsoft Azure - Using Table Parameter in Azure CLI
In this article, you'll learn how to use the Table Parameter to change the format of the output when you're issuing commands with the Azure CLI. When you're working with version 2.0 of the Azure CLI, the results from the commands that you're on are typically returned to you in the JSON format. So, for instance, if we want to search for our resource
2 min read
Microsoft Azure -Create a User in Microsoft Entra ID from Azure Portal
A user in Microsoft Entra ID is an individual who can get access to Azure identity. This Microsoft Entra ID identity can be used to access applications and resources that are protected within the organization or project. Users can be created manually or automatically, and they can be assigned to groups and roles to control their access permissions.
3 min read
Microsoft Azure- Disk Storage in Microsoft Azure
Azure Disk Storage is the only shared cloud block storage that supports both Windows and Linux-based clustered or high-availability applications via Azure shared disks. There are two types of Disks in Azure : Managed Disks Unmanaged Disks.Managed DisksSimplest optionLower management overhead as Azure manages the storage accounts.Only LRS replicatio
6 min read
Pitfalls to Avoid When Using Spot VMs in GKE for Cost Reduction
Google Kubernetes Engine (GKE) offers on-demand and spot VMs for running user workloads (pods, deployments, and daemon sets), providing a low-cost solution to run specific workloads within your Kubernetes cluster. Spot VMs are unused Compute Engine instances within a cloud provider's data center available at a significant discount. Spot VMs are an
6 min read
Microsoft Azure - VM CPU Utilisation Across Subscriptions with Range
Here, In this article, we will be finding the Azure Virtual Machines across azure subscriptions where Average CPU Utilization in range and displaying only the results of only top utilized or underutilized VMs across subscriptions in descending order or in ascending order. By using the below KQL Queries you can fetch the azure data source results by
4 min read
Identify and Diagnose Apps with High Memory in Microsoft Azure
This article serves as a step-by-step guide to help us identify and diagnose applications with high memory usage in Microsoft Azure. Understanding the primary terminologies involved is crucial for effective troubleshooting and optimization. By following the steps given below, we will be able to analyze memory usage patterns, detect potential memory
6 min read