gpt4 book ai didi

azure - 如何在azure powershell中获取1天时间粒度的指标数据?

转载 作者:行者123 更新时间:2023-12-03 05:42:07 28 4
gpt4 key购买 nike

我想要虚拟机的 90 天 Azure 指标,时间粒度为 1 天,即 24 小时。我正在尝试它因错误请求错误而失败。

Get-AzureRMMetric -ResourceId $vm[0].Id -TimeGrain 24:00:00 -MetricName "Percentage CPU" -StartTime (Get-Date).adddays(-90) -EndTime (Get-Date)

错误如下

Get-AzureRMMetric : Exception type: ErrorResponseException, Message: Microsoft.Azure.Management.Monitor.Models.ErrorResponseException: 
Operation returned an invalid status code 'BadRequest'
at Microsoft.Azure.Management.Monitor.MetricsOperations.<ListWithHttpMessagesAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.Management.Monitor.MetricsOperationsExtensions.<ListAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.Commands.Insights.Metrics.GetAzureRmMetricCommand.ProcessRecordInternal()
at Microsoft.Azure.Commands.Insights.MonitorCmdletBase.ExecuteCmdlet(), Code: Null, Status code:Null, Reason phrase: Null
At line:1 char:9
+ $metric=Get-AzureRMMetric -ResourceId $vm[0].Id -TimeGrain 24:00:00 - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-AzureRmMetric], PSInvalidOperationException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Insights.Metrics.GetAzureRmMetricCommand

最佳答案

powershell -Timegrain 的语法是

d.HH:MM:ss

因此,要在请求中获得 1 天的时间跨度,您可以编写

-TimeGrain 1.00:00:00

希望这有帮助。问候,约翰。

关于azure - 如何在azure powershell中获取1天时间粒度的指标数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57922767/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com