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.

The retrieving systems metrics are designed to give assess and know how it will be easy to use the search results to satisfy the user’s query concern. Generally, these metrics are categorized into online and offline metrics. Talking about the online metrics, these are related to user’s interactions with the search system. While on the other hand, offline metrics are entirely related to the search engine result page and meet the expectations of the users.

 

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.

Conclusion

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!