Retrieving System metrics from Azure using Monitoring API

In this blog, we will further explore python SDK for Azure and some of the key APIs that can be used to generate performance reports.

Retrieving system metrics are designed to give an assessment and to know how easy it will be to use the results of the search to satisfy the user’s query concerns. Generally, these metrics are categorized as online and offline metrics. Talking about online metrics, they relate to user interactions with the search system. On the other hand, offline metrics are directly linked to the results page of the search engine and meet the user’s expectations.


Problem Statement

Preparing system performance report sometimes can be overwhelming as there is no availability of reporting features rather than visualization of those metrics in Azure Monitor. We are here discussing primary points proven to be useful or developers who are facing the below pain points.

  • Only VM can quickly obtain metrics at a time of console level. Even the task gets tedious at the time of the increased number of Virtual machines.
  • It is reported that obtained data has to be tailored depending on the requirements. But, mind that such customizations are not performed at the console level.
  • At present, there are no such monitoring tools on which you can rely on when it is about custom report generation.

APIs to the rescue…

For specific actions, there are numerous API’s available for several individual services. All of them are offered by Azure based on the customer’s requirements.

Here, we are exploring python SDK for Azure and some of the critical APIs needed for generating performance reports. Well, it can also be done while using Azure CLI. On the other hand, the Python SDK is also a bit more expedient and modified as per the necessities. The whole process can be categorized into four parts that are explained below.

  1. Authentication:

Authentication of API call is considered to be the foremost step. For this process, the best thing is to utilize the Service Principle. This principle gives access to monitoring of services and computers.

  1. Context Setting:

The next step is making the list of virtual machines having access to service principles. This data will be used in the next step to retrieve the metrics of the same.

  1. Metrics Retrieval:

In the next step, there is access to retrieve the system metrics like CPU utilization, Network in, and Network out from Azure. These metrics are required for a virtual machine offered for a predefined time frame along with a specific granularity of metrics data.

  1. Output Handling:

Being the final step, in output handling, we have to write the data retrieved procured in the above step to a CSV file. It is further modified completely, depending on the requirement.


We have used Azure API to retrieve system metrics and customize it based on our requirements. As with any other API based services, this feature of Azure also opens up a lot of possibilities for automation.

Leave your feedback, and do not hesitate to extend and update the scripts as per your requirement.


Written by,

Sripranav P – Cloud Engineer, 1CloudHub

Sharing is caring!

Subscribe to our Newsletter1CloudHub