休息 – Azure Microsoft Insights API 2016-09-01收集指标时出错

前端之家收集整理的这篇文章主要介绍了休息 – Azure Microsoft Insights API 2016-09-01收集指标时出错前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
请帮助我理解为什么从最近几天Azure Microsoft Insights API 2016-09-01发出以下错误{
“code”:“BadRequest”,
“message”:“只有’< name> eq< value>‘形式的条件允许,其中< name> =’timeGrain’,’startTime’,’endTime’,’name.value’,’aggregationType’,’debugRegion’:( name.value eq’Disk Write Bytes’)和timeGrain eq duration ‘PT5M’和startTime eq 2017-10-25T13:27:49.620 0000和endTime eq 2017-10-25T13:32:49.620 0000“
}

几天前它工作正常老工作网址—> https://management.azure.com/subscriptions/452529bb-083b-411a-a5c2-30c735222/resourceGroups/Preprod2-Resource-Group/providers/Microsoft.Compute/virtualMachines/mw-mcs-test3/providers/microsoft.insights/ metrics?api-version = 2016-09-01& $filter =(name.value eq’磁盘写操作/秒’或name.value eq’百分比cpu’或name.value eq’Network In’或name.value eq ‘Network Out’或name.value eq’Disk Read Operations / Sec’或name.value eq’Disk Read Bytes’或name.value eq’Disk Write Bytes’)和timeGrain eq duration’PT5M’和startTime eq 2017-05 -26T10:52:28.475 + 0000和endTime eq 2017-05-26T10:57:28.476 + 0000

新的无效网址—> https://management.azure.com/subscriptions/452529bb-083b-411a-a5c2-30c735222/resourceGroups/MWatchLab-dev-kafka-bridge-oldcore-357248/providers/Microsoft.Compute /virtualMachines/dev-kafka-bridge-oldcore/providers/microsoft.insights/metrics?api-version=2016-09-01\u0026amp;$filter=(name.value eq’Disk Write Operations / Sec’或name.value eq’百分比cpu’或name.value eq’Network In’或name.value eq’Network Out’或name.value eq’Disk Read Operations / Sec’或name.value eq’Disk Read Bytes’或name.value eq’Disk写字节’)和timeGrain eq持续时间’PT5M’和startTime eq 2017-10-26T05:28:34.919 + 0000和endTime eq 2017-10-26T05:33:34.919 + 0000

请帮我解决这个问题,这在我的生产环境中造成了巨大的问题.

当指标名称没有“()”时,我可以重新发出问题.

我假设你提到不工作的URL不对应你的错误信息.正如您所提到的,2 URL只是资源组和虚拟机名称不相同,排除开始时间和结束时间.请尝试使用以下URL再次测试它.它在我身边正常工作.

https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourcegroup}/providers/Microsoft.Compute/virtualMachines/{machineName}/providers/microsoft.insights/metrics?$filter=(%20name.value%20eq%20'Disk%20Write%20Operations/Sec'%20or%20%20name.value%20eq%20'Percentage%20cpu'%20or%20%20name.value%20eq%20'Network%20In'%20or%20%20name.value%20eq%20'Network%20Out'%20or%20%20name.value%20eq%20'Disk%20Read%20Operations/Sec'%20or%20%20name.value%20eq%20'Disk%20Read%20Bytes'%20or%20%20name.value%20eq%20'Disk%20Write%20Bytes'%20%20)%20and%20timeGrain%20eq%20duration'PT5M'%20and%20startTime%20eq%202017-10-26T05:28:34.919Z%20and%20endTime%20eq%202017-10-26T05:33:34.919&api-version=2016-09-01

如果使用C#SDK是可以接受的,我们可以使用Microsoft.Azure.Management.Monitor.Fluent,以下是我的演示代码,它在我这边正常工作.

var azureTenantId = "tenant id";
var azureSecretKey = "secret key";
var azureAppId = "client id";
var subscriptionId = "subscription id";
var resourceGroup = "resource group";
var machineName = "machine name";
var serviceCreds = ApplicationTokenProvider.LoginSilentAsync(azureTenantId,azureAppId,azureSecretKey).Result;
MonitorClient monitorClient = new MonitorClient(serviceCreds) { SubscriptionId = subscriptionId };
 var resourceUrl = $"subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{machineName}";
 var metricNames = "(name.value eq 'Disk Write Operations/Sec' or  name.value eq 'Percentage cpu' or  name.value eq 'Network In' or  name.value eq 'Network Out' or  name.value eq 'Disk Read Operations/Sec' or  name.value eq 'Disk Read Bytes' or  name.value eq 'Disk Write Bytes')"; 
 string timeGrain = " and timeGrain eq duration'PT5M'";
 string startDate = " and startTime eq 2017-10-26T05:28:34.919Z";
 string endDate = " and endTime eq 2017-10-26T05:33:34.919Z";
 var odataFilterMetrics = new ODataQuery<MetricInner>(
                $"{metricNames}{timeGrain}{startDate}{endDate}");

 var metrics = monitorClient.Metrics.ListWithHttpMessagesAsync(resourceUrl,odataFilterMetrics).Result;

原文链接:https://www.f2er.com/windows/371902.html

猜你在找的Windows相关文章