Edit

Share via


Get-AzMetric

Gets the metric values of a resource.

Syntax

GetWithDefaultParameters (Default)

Get-AzMetric
    [-ResourceId] <String>
    [[-MetricName] <String[]>]
    [-TimeGrain <TimeSpan>]
    [-StartTime <DateTime>]
    [-EndTime <DateTime>]
    [-DetailedOutput]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

GetWithFullParameters

Get-AzMetric
    [-ResourceId] <String>
    [-MetricName] <String[]>
    [-TimeGrain <TimeSpan>]
    [-AggregationType <AggregationType>]
    [-StartTime <DateTime>]
    [-EndTime <DateTime>]
    [-Top <Int32>]
    [-OrderBy <String>]
    [-MetricNamespace <String>]
    [-ResultType <ResultType>]
    [-MetricFilter <String>]
    [-DetailedOutput]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

Description

The Get-AzMetric cmdlet gets the metric values for a specified resource.

Examples

Example 1: Get a metric with summarized output

PS C:\>Get-AzMetric -ResourceId "/subscriptions/a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1/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/a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1/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/a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1/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-AzMetric -ResourceId "/subscriptions/a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1/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/a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1/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-AzMetric -ResourceId "/subscriptions/a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1/resourceGroups/Default-Web-EastUS/providers/microsoft.web/sites/website3" -MetricName "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/a0a0a0a0-bbbb-cccc-dddd-e1e1e1e1e1e1/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-AzMetricFilter -Dimension City -Operator eq -Value "Seattle","Toronto"), (New-AzMetricFilter -Dimension AuthenticationType -Operator eq -Value User))

PS C:\> Get-AzMetric -ResourceId <resourceId> -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 dimension filter and aggregation type.

Parameters

-AggregationType

The aggregation type of the query

Parameter properties

Type:

Nullable<T>[Microsoft.Azure.Management.Monitor.Models.AggregationType]

Default value:None
Accepted values:None, Average, Count, Minimum, Maximum, Total
Supports wildcards:False
DontShow:False

Parameter sets

GetWithFullParameters
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure.

Parameter properties

Type:IAzureContextContainer
Default value:None
Supports wildcards:False
DontShow:False
Aliases:AzContext, AzureRmContext, AzureCredential

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DetailedOutput

Indicates that this cmdlet displays detailed output. By default, output is summarized.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-EndTime

Specifies the end time of the query in local time. The default is the current time.

Parameter properties

Type:DateTime
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-MetricFilter

Specifies the metric dimension filter to query metrics for.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

GetWithFullParameters
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-MetricName

Specifies an array of names of metrics.

Parameter properties

Type:

String[]

Default value:None
Supports wildcards:False
DontShow:False
Aliases:MetricNames

Parameter sets

GetWithDefaultParameters
Position:1
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-MetricNamespace

Specifies the metric namespace to query metrics for.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

GetWithFullParameters
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-OrderBy

Specifies the aggregation to use for sorting results and the direction of the sort (Example: sum asc).

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

GetWithFullParameters
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-ResourceId

Specifies the resource ID of the metric.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:0
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-ResultType

Specifies the result type to be returned (metadata or data).

Parameter properties

Type:

Nullable<T>[Microsoft.Azure.Management.Monitor.Models.ResultType]

Default value:None
Accepted values:Data, Metadata
Supports wildcards:False
DontShow:False

Parameter sets

GetWithFullParameters
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-StartTime

Specifies the start time of the query in local time. The default is the current local time minus one hour.

Parameter properties

Type:DateTime
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-TimeGrain

Specifies the time grain of the metric as a TimeSpan object in the format hh:mm:ss.

Parameter properties

Type:TimeSpan
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-Top

Specifies the maximum number of records to retrieve (default:10), to be specified with $filter.

Parameter properties

Type:

Nullable<T>[Int32]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

GetWithFullParameters
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

String

TimeSpan

Nullable<T>

DateTime

Nullable<T>

Nullable<T>

String

SwitchParameter

Outputs

PSMetric

Notes

More information about the supported metrics may be found at: https://learn.microsoft.com/en-us/azure/azure-monitor/platform/metrics-supported