Jagamisviis:


az monitor metrics

View Azure resource metrics.

Commands

Name Description Type Status
az monitor metrics alert

Manage near-realtime metric alert rules.

Core GA
az monitor metrics alert condition

Manage near-realtime metric alert rule conditions.

Core GA
az monitor metrics alert condition create

Build a metric alert rule condition.

Core Preview
az monitor metrics alert create

Create a metric-based alert rule.

Core GA
az monitor metrics alert delete

Delete a metrics-based alert rule.

Core GA
az monitor metrics alert dimension

Manage near-realtime metric alert rule dimensions.

Core GA
az monitor metrics alert dimension create

Build a metric alert rule dimension.

Core Preview
az monitor metrics alert list

List metric-based alert rules.

Core GA
az monitor metrics alert show

Show a metrics-based alert rule.

Core GA
az monitor metrics alert update

Update a metric-based alert rule.

Core GA
az monitor metrics list

List the metric values for a resource.

Core GA
az monitor metrics list-definitions

List the metric definitions for the resource.

Core GA
az monitor metrics list-namespaces

List the metric namespaces for the resource.

Core Preview
az monitor metrics list-sub

Lists the metric data for a subscription. Parameters can be specified on the body.

Core GA
az monitor metrics list-sub-definitions

List the metric definitions for the subscription.

Core GA

az monitor metrics list

List the metric values for a resource.

az monitor metrics list --resource
                        [--aggregation {Average, Count, Maximum, Minimum, None, Total}]
                        [--dimension]
                        [--end-time]
                        [--filter]
                        [--interval]
                        [--metadata]
                        [--metrics]
                        [--namespace]
                        [--offset]
                        [--orderby]
                        [--resource-group]
                        [--resource-namespace]
                        [--resource-parent]
                        [--resource-type]
                        [--start-time]
                        [--top]

Examples

List a VM's CPU usage for the past hour

az monitor metrics list --resource {ResourceName} --metric "Percentage CPU"

List success E2E latency of a storage account and split the data series based on API name

az monitor metrics list --resource {ResourceName} --metric SuccessE2ELatency \
                        --dimension ApiName

List success E2E latency of a storage account and split the data series based on both API name and geo type

az monitor metrics list --resource {ResourceName} --metric SuccessE2ELatency \
                        --dimension ApiName GeoType

List success E2E latency of a storage account and split the data series based on both API name and geo type using "--filter" parameter

az monitor metrics list --resource {ResourceName} --metric SuccessE2ELatency \
                        --filter "ApiName eq '*' and GeoType eq '*'"

List success E2E latency of a storage account and split the data series based on both API name and geo type. Limits the api name to 'DeleteContainer'

az monitor metrics list --resource {ResourceName} --metric SuccessE2ELatency \
                        --filter "ApiName eq 'DeleteContainer' and GeoType eq '*'"

List transactions of a storage account per day since 2017-01-01

az monitor metrics list --resource {ResourceName} --metric Transactions \
                        --start-time 2017-01-01T00:00:00Z \
                        --interval PT24H

List the metadata values for a storage account under transaction metric's api name dimension since 2017

az monitor metrics list --resource {ResourceName} --metric Transactions \
                        --filter "ApiName eq '*'" \
                        --start-time 2017-01-01T00:00:00Z

Required Parameters

--resource

Name or ID of the target resource.

Optional Parameters

--aggregation

The list of aggregation types (space-separated) to retrieve.

Accepted values: Average, Count, Maximum, Minimum, None, Total
Value from: az monitor metrics list-definitions
--dimension

The list of dimensions (space-separated) the metrics are queried into.

Value from: az monitor metrics list-definitions
--end-time

End time of the query. Defaults to the current time. Format: date (yyyy-mm-dd) time (hh:mm:ss.xxxxx) timezone (+/-hh:mm).

--filter

A string used to reduce the set of metric data returned. eg. "BlobType eq '*'".

For a full list of filters, see the filter string reference at https://docs.microsoft.com/rest/api/monitor/metrics/list.

--interval

The interval over which to aggregate metrics, in ##h##m format.

Default value: 1m
--metadata

Returns the metadata values instead of metric data.

--metrics

Space-separated list of metric names to retrieve.

Value from: az monitor metrics list-definitions
--namespace

Namespace to query metric definitions for.

Value from: az monitor metrics list-namespaces
--offset

Time offset of the query range, in ##d##h format.

Can be used with either --start-time or --end-time. If used with --start-time, then the end time will be calculated by adding the offset. If used with --end-time (default), then the start time will be calculated by subtracting the offset. If --start-time and --end-time are provided, then --offset will be ignored.

Default value: 1h
--orderby

Aggregation to use for sorting results and the direction of the sort. Only one order can be specificed. Examples: sum asc.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--resource-namespace

Target resource provider namespace.

--resource-parent

Target resource parent path, if applicable.

--resource-type

Target resource type. Can also accept namespace/type format (Ex: 'Microsoft.Compute/virtualMachines').

--start-time

Start time of the query. Format: date (yyyy-mm-dd) time (hh:mm:ss.xxxxx) timezone (+/-hh:mm).

--top

Max number of records to retrieve.

Default value: 10
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az monitor metrics list-definitions

List the metric definitions for the resource.

az monitor metrics list-definitions --resource
                                    [--namespace]
                                    [--resource-group]
                                    [--resource-namespace]
                                    [--resource-parent]
                                    [--resource-type]

Examples

List the metric definitions for the resource. (autogenerated)

az monitor metrics list-definitions --resource /subscriptions/{subscriptionID}/resourceGroups/{resourceGroup}/Microsoft.Network/networkSecurityGroups/{resourceName}

Required Parameters

--resource

Name or ID of the target resource.

Optional Parameters

--namespace

Namespace to query metric definitions for.

Value from: az monitor metrics list-namespaces
--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--resource-namespace

Target resource provider namespace.

--resource-parent

Target resource parent path, if applicable.

--resource-type

Target resource type. Can also accept namespace/type format (Ex: 'Microsoft.Compute/virtualMachines').

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az monitor metrics list-namespaces

Preview

This command is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus

List the metric namespaces for the resource.

az monitor metrics list-namespaces --resource-uri
                                   [--start-time]

Examples

List the metric namespaces for the resource.

az monitor metrics list-namespaces --resource /subscriptions/{subscriptionID}/resourceGroups/{resourceGroup}/Microsoft.Network/networkSecurityGroups/{resourceName} --start-time 2021-03-01T00:00:00Z

Required Parameters

--resource-uri

The identifier of the resource.

Optional Parameters

--start-time

Start time of the query. Format: date (yyyy-mm-dd) time (hh:mm:ss.xxxxx) timezone (+/-hh:mm).

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az monitor metrics list-sub

Lists the metric data for a subscription. Parameters can be specified on the body.

az monitor metrics list-sub --region
                            [--aggregation]
                            [--auto-adjust-timegrain {0, 1, f, false, n, no, t, true, y, yes}]
                            [--filter]
                            [--interval]
                            [--metricnames]
                            [--metricnamespace]
                            [--order-by]
                            [--result-type {Data, Metadata}]
                            [--roll-up-by]
                            [--timespan]
                            [--top]
                            [--validate-dimensions {0, 1, f, false, n, no, t, true, y, yes}]

Required Parameters

--region

The region where the metrics you want reside.

Optional Parameters

--aggregation

The list of aggregation types (comma separated) to retrieve.

--auto-adjust-timegrain

When set to true, if the timespan passed in is not supported by this metric, the API will return the result using the closest supported timespan. When set to false, an error is returned for invalid timespan parameters. Defaults to false.

Accepted values: 0, 1, f, false, n, no, t, true, y, yes
--filter

The $filter is used to reduce the set of metric data returned.
Example:
Metric contains metadata A, B and C.
- Return all time series of C where A = a1 and B = b1 or b2
$filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’
- Invalid variant:
$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’
This is invalid because the logical or operator cannot separate two different metadata names.
- Return all time series where A = a1, B = b1 and C = c1:
$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’
- Return all time series where A = a1
$filter=A eq ‘a1’ and B eq ‘’ and C eq ‘.

--interval

The interval (i.e. timegrain) of the query in ISO 8601 duration format. Defaults to PT1M. Special case for 'FULL' value that returns single datapoint for entire time span requested. Examples: PT15M, PT1H, P1D, FULL.

--metricnames

The names of the metrics (comma separated) to retrieve.

--metricnamespace

Metric namespace where the metrics you want reside.

--order-by

The aggregation to use for sorting results and the direction of the sort. Only one order can be specified. Examples: sum asc.

--result-type

Reduces the set of data collected. The syntax allowed depends on the operation. See the operation's description for details.

Accepted values: Data, Metadata
--roll-up-by

Dimension name(s) to rollup results by. For example if you only want to see metric values with a filter like 'City eq Seattle or City eq Tacoma' but don't want to see separate values for each city, you can specify 'RollUpBy=City' to see the results for Seattle and Tacoma rolled up into one timeseries.

--timespan

The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'.

--top

The maximum number of records to retrieve. Valid only if $filter is specified. Defaults to 10.

--validate-dimensions

When set to false, invalid filter parameter values will be ignored. When set to true, an error is returned for invalid filter parameters. Defaults to true.

Accepted values: 0, 1, f, false, n, no, t, true, y, yes
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az monitor metrics list-sub-definitions

List the metric definitions for the subscription.

az monitor metrics list-sub-definitions --region
                                        [--metricnamespace]

Required Parameters

--region

The region where the metrics you want reside.

Optional Parameters

--metricnamespace

Metric namespace where the metrics you want reside.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.