Azure / azure-rest-api-specs

The source for REST API specifications for Microsoft Azure.
MIT License
2.53k stars 4.96k forks source link

Dimension or Split By option not available in azure-monitor-mgmt client "metrics.list" method #21948

Open dattasoumya92 opened 1 year ago

dattasoumya92 commented 1 year ago

An option like Dimension or Split By should be provided which is currently not available in azure-monitor-mgmt client "metrics.list" method .
Package class: azure.mgmt.monitor._monitor_management_client.MonitorManagementClient Operation Method: metrics.list()

A "--dimension" option which is provided in az cli command , similar parameter can be provided in its python sdk counterpart -

az monitor metrics list --resource {ResourceName} --aggregation Total --dimension "ResponseType" --metric Transactions --start-time 2022-12-08T16:00:00Z --interval PT1H

Az CLI Reference from: https://learn.microsoft.com/en-us/cli/azure/monitor/metrics?view=azure-cli-latest#az-monitor-metrics-list

Az monitor metrics Python SDK Reference from: https://learn.microsoft.com/en-us/python/api/azure-mgmt-monitor/azure.mgmt.monitor.v2018_01_01.operations.metricsoperations?view=azure-python#azure-mgmt-monitor-v2018-01-01-operations-metricsoperations-list

kashifkhan commented 1 year ago

Thank you for the feedback @dattasoumya92 . We will investigate asap

ghost commented 1 year ago

Thank you for your feedback. This has been routed to the support team for assistance.

ghost commented 1 year ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @SameergMS, @dadunl.

Issue Details
An option like Dimension or Split By should be provided which is currently not available in azure-monitor-mgmt client "metrics.list" method . Package class: azure.mgmt.monitor._monitor_management_client.MonitorManagementClient Operation Method: metrics.list() A "--dimension" option which is provided in az cli command , similar parameter can be provided in its python sdk counterpart - ```bash az monitor metrics list --resource {ResourceName} --aggregation Total --dimension "ResponseType" --metric Transactions --start-time 2022-12-08T16:00:00Z --interval PT1H ``` Az CLI Reference from: https://learn.microsoft.com/en-us/cli/azure/monitor/metrics?view=azure-cli-latest#az-monitor-metrics-list Az monitor metrics Python SDK Reference from: https://learn.microsoft.com/en-us/python/api/azure-mgmt-monitor/azure.mgmt.monitor.v2018_01_01.operations.metricsoperations?view=azure-python#azure-mgmt-monitor-v2018-01-01-operations-metricsoperations-list
Author: dattasoumya92
Assignees: msyyc
Labels: `question`, `Monitor`, `Service Attention`, `Mgmt`, `customer-reported`
Milestone: -
SaurabhSharma-MSFT commented 1 year ago

@kashifkhan Thanks for you feedback, we are routing this issue to respective team to look into.

Wzb123456789 commented 1 year ago

Hi @dattasoumya92 You can try to refer to this Sample to solve your problem: https://github.com/Azure-Samples/azure-samples-python-management/blob/main/samples/monitor/manage_metric_list.py

dattasoumya92 commented 1 year ago

Hi @dattasoumya92 You can try to refer to this Sample to solve your problem: https://github.com/Azure-Samples/azure-samples-python-management/blob/main/samples/monitor/manage_metric_list.py

Hi @Wzb123456789 : The sample that you provided does not resolve my issue. The code you provided lets me filter the metric data result which is not what I'm looking for. Let me re-iterate one more time for better understanding --

In the cli version of "monitor metrics list" , the option --dimension "ResponseType" acts as a "Group By" function i.e. it groups the metric result in groups of distinct "ResponseType" values. And the issue I stated above is that this particular function is NOT available in the python sdk version of "monitor metrics list", i.e. MonitorManagementClient: metrics.list()

Hoping to get a response soon.

Wzb123456789 commented 1 year ago

Since the SDK is generated by swagger, it is responsible for receiving the data returned by the service and displaying it to the user after processing, so the SDK will not modify or delete a certain parameter.

There is no operation similar to group by in the swagger definition, so there is no similar operation in the generated Python SDK.

swagger definition: https://github.com/Azure/azure-rest-api-specs/blob/main/specification/monitor/resource-manager/Microsoft.Insights/stable/2018-01-01/metrics_API.json#L41

klaska-lukas commented 9 months ago

As a workaround I use a filter in client.query_resource() function. You need to get familiar with the dimension names first and use filter like: filter="Power Supply eq '*'" or filter="Component eq '*' and Controller eq '*' and Index eq '*'" for multidimensional metrics. You may need to set max_results to a higher value (default is 10).