Get-AzureRmMetric
Gets the metric values of a resource.
Warning
The AzureRM PowerShell module has been officially deprecated as of February 29, 2024. Users are advised to migrate from AzureRM to the Az PowerShell module to ensure continued support and updates.
Although the AzureRM module may still function, it's no longer maintained or supported, placing any continued use at the user's discretion and risk. Please refer to our migration resources for guidance on transitioning to the Az module.
Syntax
Get-AzureRmMetric
[-ResourceId] <String>
[-TimeGrain <TimeSpan>]
[-StartTime <DateTime>]
[-EndTime <DateTime>]
[[-MetricName] <String[]>]
[-DetailedOutput]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Get-AzureRmMetric
[-ResourceId] <String>
[-TimeGrain <TimeSpan>]
[-AggregationType <AggregationType>]
[-StartTime <DateTime>]
[-EndTime <DateTime>]
[-Top <Int32>]
[-OrderBy <String>]
[-MetricNamespace <String>]
[-ResultType <ResultType>]
[-MetricFilter <String>]
[-MetricName] <String[]>
[-DetailedOutput]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Description
The Get-AzureRmMetric cmdlet gets the metric values for a specified resource.
Examples
Example 1: Get a metric with summarized output
PS C:\>Get-AzureRmMetric -ResourceId "/subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3" -TimeGrain 00:01:00
DimensionName :
DimensionValue :
Name : AverageResponseTime
EndTime : 3/20/2015 6:40:46 PM
MetricValues : {Microsoft.Azure.Insights.Models.MetricValue, Microsoft.Azure.Insights.Models.MetricValue,
Microsoft.Azure.Insights.Models.MetricValue, Microsoft.Azure.Insights.Models.MetricValue...}
Properties : {}
ResourceId : /subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3
StartTime : 3/20/2015 5:40:00 PM
TimeGrain : 00:01:00
Unit : Seconds
DimensionName :
DimensionValue :
Name : AverageMemoryWorkingSet
EndTime : 3/20/2015 6:40:46 PM
MetricValues : {Microsoft.Azure.Insights.Models.MetricValue, Microsoft.Azure.Insights.Models.MetricValue,
Microsoft.Azure.Insights.Models.MetricValue, Microsoft.Azure.Insights.Models.MetricValue...}
Properties : {}
ResourceId : /subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3
StartTime : 3/20/2015 5:40:00 PM
TimeGrain : 00:01:00
Unit : Bytes
This command gets the metric values for website3 with a time grain of 1 minute.
Example 2: Get a metric with detailed output
PS C:\>Get-AzureRmMetric -ResourceId "/subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3" -TimeGrain 00:01:00 -DetailedOutput
MetricValues :
Average : 0
Count : 1
Last :
Maximum :
Minimum :
Properties :
Timestamp : 3/20/2015 6:37:00 PM
Total : 0
Average : 0.106
Count : 1
Last :
Maximum :
Minimum :
Properties :
Timestamp : 3/20/2015 6:39:00 PM
Total : 0.106
Average : 0.064
Count : 1
Last :
Maximum :
Minimum :
Properties :
Timestamp : 3/20/2015 6:41:00 PM
Total : 0.064
Properties :
DimensionName :
DimensionValue :
Name : AverageResponseTime
EndTime : 3/20/2015 6:43:33 PM
ResourceId : /subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3
StartTime : 3/20/2015 5:43:00 PM
TimeGrain : 00:01:00
Unit : Seconds
This command gets the metric values for website3 with a time grain of 1 minute. The output is detailed.
Example 3: Get detailed output for a specified metric
PS C:\>Get-AzureRmMetric -ResourceId "/subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3" -MetricNames "Requests" -TimeGrain 00:01:00 -DetailedOutput
MetricValues :
Average : 1
Count : 1
Last :
Maximum :
Minimum :
Properties :
Timestamp : 3/20/2015 6:39:00 PM
Total : 1
Average : 1
Count : 1
Last :
Maximum :
Minimum :
Properties :
Timestamp : 3/20/2015 6:41:00 PM
Total : 1
Average : 0
Count : 1
Last :
Maximum :
Minimum :
Properties :
Timestamp : 3/20/2015 6:43:00 PM
Total : 0
Average : 1
Count : 1
Last :
Maximum :
Minimum :
Properties :
Timestamp : 3/20/2015 6:44:00 PM
Total : 1
Average : 0
Count : 1
Last :
Maximum :
Minimum :
Properties :
Timestamp : 3/20/2015 6:45:00 PM
Total : 0
Properties :
DimensionName :
DimensionValue :
Name : Requests
EndTime : 3/20/2015 6:47:56 PM
ResourceId : /subscriptions/e3f5b07d-3c39-4b0f-bf3b-40fdeba10f2a/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3
StartTime : 3/20/2015 5:47:00 PM
TimeGrain : 00:01:00
Unit : Count
This command gets detailed output for the Requests metric.
Example 4: Get summarized output for a specified metric with specified dimension filter
PS C:\> $dimFilter = @((New-AzureRmMetricFilter -Dimension City -Operator eq -Values "Seattle","Toronto"), (New-AzureRmMetricDimensionFilter -Dimension AuthenticationType -Operator eq -Values User))
PS C:\> Get-AzureRmMetricValues -ResourceId <resourcId> -MetricName PageViews -TimeGrain PT5M -MetricFilter $dimFilter -StartTime 2018-02-01T12:00:00Z -EndTime 2018-02-01T12:10:00Z -AggregationType -Average
ResourceId : [ResourceId]
MetricNamespace : Microsoft.Insights/ApplicationInsights
Metric Name :
LocalizedValue : Page Views
Value : PageViews
Unit : Seconds
Timeseries :
City : Seattle
AuthenticationType : User
Timestamp : 2018-02-01 12:00:00 PM
Average : 3518
Timestamp : 2018-02-01 12:05:00 PM
Average : 1984
City : Toronto
AuthenticationType : User
Timestamp : 2018-02-01 12:00:00 PM
Average : 894
Timestamp : 2018-02-01 12:05:00 PM
Average : 967
This command gets summarized output for the PageViews metric with specified dimesion filter and aggregation type.
Parameters
-AggregationType
The aggregation type of the query
Type: | Nullable<T>[AggregationType] |
Accepted values: | None, Average, Count, Minimum, Maximum, Total |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with azure.
Type: | IAzureContextContainer |
Aliases: | AzureRmContext, AzureCredential |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-DetailedOutput
Indicates that this cmdlet displays detailed output. By default, output is summarized.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-EndTime
Specifies the end time of the query in local time. The default is the current time.
Type: | DateTime |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-MetricFilter
Specifies the metric dimension filter to query metrics for.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-MetricName
Specifies an array of names of metrics.
Type: | String[] |
Aliases: | MetricNames |
Position: | 1 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-MetricNamespace
Specifies the metric namespace to query metrics for.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-OrderBy
Specifies the aggregation to use for sorting results and the direction of the sort (Example: sum asc).
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-ResourceId
Specifies the resource ID of the metric.
Type: | String |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-ResultType
Specifies the result type to be returned (metadata or data).
Type: | Nullable<T>[ResultType] |
Accepted values: | Data, Metadata |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-StartTime
Specifies the start time of the query in local time. The default is the current local time minus one hour.
Type: | DateTime |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-TimeGrain
Specifies the time grain of the metric as a TimeSpan object in the format hh:mm:ss.
Type: | TimeSpan |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Top
Specifies the maximum number of records to retrieve (default:10), to be specified with $filter.
Type: | Nullable<T>[Int32] |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Inputs
Nullable<T>[[Microsoft.Azure.Management.Monitor.Models.AggregationType, Microsoft.Azure.Management.Monitor, Version=0.19.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]
Nullable<T>[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]
Nullable<T>[[Microsoft.Azure.Management.Monitor.Models.ResultType, Microsoft.Azure.Management.Monitor, Version=0.19.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]
String[]