【发布时间】:2018-12-19 04:31:12
【问题描述】:
我的要求是获取托管在 azure 中的 Web 应用程序的平均 CPU 和内存百分比消耗。我想使用 powershell 命令获取数据 所以我尝试了以下命令并收到以下错误,请帮助。
命令 1:
Get-AzureRmAppServicePlanMetrics -ResourceGroupName 'RGname' -Name 'appserviceplan name' -StartTime ((get-date).AddHours(-1)) -Granularity PT1M -Metrics ["CPU Percentage"]
错误:
Get-AzureRmAppServicePlanMetrics : $filter. Details: Microsoft.Data.OData.ODataException: Syntax error at position 82 in 'name/value eq
'CPU Percentage'and startTime eq '2018-12-19T13:52:33Zand' timeGrain eq 'duration''PT1M''''.
at Microsoft.Data.OData.Query.ExpressionLexer.ValidateToken(ExpressionTokenKind t)
at Microsoft.Data.OData.Query.UriQueryExpressionParser.ParseFilter(String filter)
at Microsoft.Data.OData.Query.ODataUriParser.ParseFilterImplementation(String filter, IEdmType elementType, IEdmEntitySet entitySet)
at Microsoft.Web.Hosting.Administration.Csm.Common.ODataFilterParser.ParseMetricsFilterQuery(IEnumerable`1 queryNameValuePairs, String&
names, String& startTime, String& endTime, String& timeGrain).
name/value eq 'CPU Percentage'and startTime eq '2018-12-19T13:52:33Zand' timeGrain eq 'duration''PT1M''' is invalid.
At line:1 char:1
+ Get-AzureRmAppServicePlanMetrics -ResourceGroupName 'resource group name ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-AzureRmAppServicePlanMetrics], CloudException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.WebApps.Cmdlets.WebApps.GetAzureAppServicePlanMetricsCmdlet
命令 2:
Get-AzureRmAppServicePlanMetrics -ResourceGroupName 'RGname' -Name 'web app name' -StartTime ((get-date).AddHours(-1)) -Granularity PT1M -Metrics ["CPU Percentage"]
错误:
Get-AzureRmAppServicePlanMetrics : Can not perform requested operation on nested resource. Parent resource 'web app name' not found.
At line:1 char:1
+ Get-AzureRmAppServicePlanMetrics -ResourceGroupName 'resource group name...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-AzureRmAppServicePlanMetrics], CloudException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.WebApps.Cmdlets.WebApps.GetAzureAppServicePlanMetricsCmdle
请在下面找到我的 Powershell 和 AzureRM 版本详细信息
PS C:\Users\xxxx> Get-Module -Name AzureRM -ListAvailable
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 6.13.1 AzureRM
Script 5.4.1 AzureRM
$PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
5 1 14409 1005
【问题讨论】: