【Azure 事件中心】通过 az rest --method get 如何获得Event Hub Entity 级的统计指标

问题描述

通过 az rest --method get  如何获得Event Hub Entity 级的统计指标?

 

问题解答

查阅文档  https://learn.microsoft.com/en-us/rest/api/monitor/metrics/list?tabs=HTTP ,  可以通过 **filter 参数指定 EntityName eq '*' ** 或者 EntityName eq '<entity-name>'

 

Windows系统的CMD中,使用AZ CLI测试:

# EntityName eq '*'
az rest --debug --method get --url "/subscriptions/&lt;your subscription id&gt;/resourceGroups/&lt;your resource group&gt;
/providers/Microsoft.EventHub/namespaces/&lt;event-hub-name&gt;/providers/microsoft.Insights/metrics?
timespan=2022-08-31T07:03:32.960Z/2022-08-31T07:57:34.794Z
&amp;interval=PT5M&amp;metricnames=IncomingRequests&amp;aggregation=total
&amp;metricNamespace=microsoft.eventhub%2Fnamespaces&amp;top=10
&amp;orderby=total desc&amp;
$filter=EntityName eq '*'
&amp;api-version=2019-07-01"

# EntityName eq 'entity-name'
az rest --method get --url "/subscriptions/&lt;your subscription id&gt;/resourceGroups/&lt;your resource group&gt;
/providers/Microsoft.EventHub/namespaces/&lt;event-hub-name&gt;/providers/microsoft.Insights/metrics?
timespan=2022-08-31T07:03:32.960Z/2022-08-31T07:57:34.794Z
&amp;interval=PT5M&amp;metricnames=IncomingRequests&amp;aggregation=total
&amp;metricNamespace=microsoft.eventhub%2Fnamespaces&amp;top=10
&amp;orderby=total desc
&amp;$filter=EntityName eq 'kafka-test'
&amp;api-version=2019-07-01"

Linux系统中,需要对url参数中的$filter进行转义,变为 $filter 。 

az rest --debug --method get --url "/subscriptions/&lt;your subscription id&gt;/resourceGroups/&lt;your resource group&gt;
/providers/Microsoft.EventHub/namespaces/&lt;event-hub-name&gt;/providers/microsoft.Insights/metrics?
timespan=2022-08-31T07:03:32.960Z/2022-08-31T07:57:34.794Z
&amp;interval=PT1M
&amp;metricnames=SuccessfulRequests
&amp;aggregation=total
&amp;metricNamespace=microsoft.eventhub%2Fnamespaces
&amp;top=10
&amp;orderby=total asc
&amp;\$filter=EntityName eq 'kafka-test'
&amp;api-version=2019-07-01"

 

参考资料

Metrics - List:https://learn.microsoft.com/en-us/rest/api/monitor/metrics/list?tabs=HTTP

 

正在加载评论...