问题描述
大家好,
一直在使用Azure Metrics处理一些自定义报告并遇到问题(两个环境都相同)
环境A:
Az.Monitor 1.0.0
PowerShell 6.1.0
环境B:
AzureRM.Insights 5.1.4  
PowerShell 5.1.17134
1)我想要实现的是 - 容器中的blob数量。它可以从度量命名空间中的UI"Blob"获得。 Gel-AzStorageBlob不是一个选项,因为每个容器中有超过1000000个blob。
2)但是,就像我一样got - powershell命令应该是这样的:
Get-AzMetric`
-ResourceId / subscriptions / {SubscriptionID} / resourceGroups / {rgNname} /providers/Microsoft.Storage/storageAccounts/{storageAccountName}`
-MetricNames BlobCount`
-MetricNamespace" blobServices /默认"
然而它什么都不返回。
* --- *所以我试着调试它并且请求是:
Absolute Uri:
https:// management。 azure.com//subscriptions/{SubscriptionID}/resourceGroups/{rgName}/providers/Microsoft.Storage/storageAccounts/{storageAccountName}/providers/microsoft.insights/metrics?timespan=2019-02-12T07:00:53.9500008Z% 2F2019-02-12T08:00:53.9500008Z&安培; metricnames = blobServices&安培; api-version = 2018-01-01& metricnamespace = blobServices%2Fdefault
但是,根据指南,请求应为:
我试过了不同metricnamespaces像斑点,blobservices和等跨度>
将  - 的。MetricNamespace" Microsoft.Storage/storageAccounts/blobServices/default"
它返回:
" message":"检测无效值:Microsoft.Storage/storageAccounts/blobServices/default查询参数:'metricnamespace',值必须为:Microsoft.Storage/storageAccounts如果提供了查询参数,您还可以
跳过此可选查询参数。"
Absolute Uri:
https://management.azure.com//subscriptions/ {SubscriptionID} / resourceGroups / {rgName} / providers / Microsoft.Storage/storageAccounts/{storageAccountName}/blobServices/default/providers/microsoft.insights/metrics?timespan=2019-02-12T07:03:00.3461219Z%2F2019-02-12T08:03:00.3461219Z&metricnames=BlobCount& api-version = 2018-01-01
所以要获得正确回应我要跑:
获取-AzMetric`
-ResourceId /subscriptions/{SubscriptionID}/resourceGroups/{rgName}/providers/Microsoft.Storage/storageAccounts/{storageAccountname } / blobServices / default`
-MetricNames BlobCount
这是一个功能还是一个错误,或者我做错了什么?
Hi guys,
Been working with Azure Metrics for some custom reports and faced with an issue (same for both env)
Environment A:
Az.Monitor 1.0.0
PowerShell 6.1.0
Environment B:
AzureRM.Insights 5.1.4
PowerShell 5.1.17134
1) What I'm trying to achieve is - number of blobs in container. It's available from UI in Metric Namespace "Blob". Gel-AzStorageBlob is not an option as there are more then 1000000 blobs in each container
2) However, as I got - powershell command should be like:
Get-AzMetric ` -ResourceId /subscriptions/{SubscriptionID}/resourceGroups/{rgNname}/providers/Microsoft.Storage/storageAccounts/{storageAccountName} ` -MetricNames BlobCount ` -MetricNamespace "blobServices/default"
However it returns nothing.
*---* So I've tried to debug it and the request is:
https://management.azure.com//subscriptions/{SubscriptionID}/resourceGroups/{rgName}/providers/Microsoft.Storage/storageAccounts/{storageAccountName}/providers/microsoft.insights/metrics?timespan=2019-02-12T07:00:53.9500008Z%2F2019-02-12T08:00:53.9500008Z&metricnames=blobServices&api-version=2018-01-01&metricnamespace=blobServices%2Fdefault
I've tried different metricnamespaces like blob , blobservices and etc.
With -MetricNamespace "Microsoft.Storage/storageAccounts/blobServices/default"it returns:
"message": "Detect invalid value: Microsoft.Storage/storageAccounts/blobServices/default for query parameter: 'metricnamespace', the value must be: Microsoft.Storage/storageAccounts if the query parameter is provided, you can also
skip this optional query parameter."
However, according to the guide the request should be:
https://management.azure.com//subscriptions/{SubscriptionID}/resourceGroups/{rgName}/providers/Microsoft.Storage/storageAccounts/{storageAccountName}/blobServices/default/providers/microsoft.insights/metrics?timespan=2019-02-12T07:03:00.3461219Z%2F2019-02-12T08:03:00.3461219Z&metricnames=BlobCount&api-version=2018-01-01
So to get the right respond I've to run:
Get-AzMetric ` -ResourceId /subscriptions/{SubscriptionID}/resourceGroups/{rgName}/providers/Microsoft.Storage/storageAccounts/{storageAccountname}/blobServices/default ` -MetricNames BlobCount
Is it a feature or a bug or I'm doing something wrong?
这篇关于Get-AzMetric MetricNamespace问题/错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!