How to fetch custom guest metric data of a vm using python sdk

Anonymous
2024-02-20T15:46:19.8233333+00:00

enter image description hereI have enabled Azure Monitor Agent on one of the VM which is pushing memory fields (Memory percentage, Memory used etc). I'm able to view the data in the metrics section under custom namespace. I would like to fetch that data with a python script. I tried to list the namespaces and metric definitions but both apis are not returning the custom namespace and custom metrics (Memory fields). Can someone help me.

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
{count} votes

1 answer

Sort by: Most helpful
  1. AnuragSingh-MSFT 21,566 Reputation points Moderator
    2024-02-23T11:14:30.59+00:00

    vinay, thank you for questions.

    Based on the screenshot, I see that you have enabled "Windows Diagnostics extension" on this VM because of which you are getting the metrics reported under "Guest (classic)" namespace. For more details on these Namespaces, see this link.

    Note that these metrics are stored in Azure Storage account in specific tables in Table storage. For details, see Data destinations. Therefore, when using Python SDK, you would have to query the storage account's Table storage to get these values. In order to utilize the Azure Monitor Metrics API/Python SDK for Azure Monitor Metrics to view these guest level metrics as collected using the diagnostic extension, the metrics being collected needs to be sent to "Azure Monitor" using Sink option. This will add a new namespace "Virtual Machine Guest" (to which the same data as collected by diagnostic extension also gets forwarded to). This namespace can be queried using the relevant SDK/APIs to get the values.

    User's image

    Hope this helps. In case the suggestion above does not help you, please add additional details along with the code/documentation being used to query the metrics using SDK, and we will review it further.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.