Skip to main content

metrics

Creates, updates, deletes, gets or lists a metrics resource.

Overview

Namemetrics
TypeResource
Idazure.monitor.metrics

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
costintegerThe integer value representing the relative cost of the query.
intervalstringThe interval (window size) for which the metric data was returned in ISO 8601 duration format with a special case for 'FULL' value that returns single datapoint for entire time span requested (Examples: PT15M, PT1H, P1D, FULL). This may be adjusted and different from what was originally requested if AutoAdjustTimegrain=true is specified. This is not present if a metadata request was made.
namespacestringThe namespace of the metrics being queried.
resourceregionstringThe region of the resource being queried for metrics.
timespanstringThe timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back from what was originally requested. Required.
valuearrayThe value of the collection. Required.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
list_at_subscription_scopeselectsubscription_id, regiontimespan, interval, metricnames, aggregation, top, orderby, $filter, resultType, metricnamespace, AutoAdjustTimegrain, ValidateDimensions, rollupbyLists the metric data for a subscription. This API used the default ARM throttling limits _.
listselectresource_uritimespan, interval, metricnames, aggregation, top, orderby, $filter, resultType, metricnamespace, AutoAdjustTimegrain, ValidateDimensions, rollupbyLists the metric values for a resource. This API used the default ARM throttling limits _.
list_at_subscription_scope_postexecsubscription_id, regiontimespan, interval, metricnames, aggregation, top, orderby, $filter, resultType, metricnamespace, AutoAdjustTimegrain, ValidateDimensions, rollupbyLists the metric data for a subscription. Parameters can be specified on either query params or the body. This API used the default ARM throttling limits _.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
regionstringThe region where the metrics you want reside. Required.
resource_uristringThe fully qualified Azure Resource manager identifier of the resource. Required.
subscription_idstring
$filterstringThe $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 ‘’**. Default value is None.
AutoAdjustTimegrainbooleanWhen 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. Default value is None.
ValidateDimensionsbooleanWhen 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. Default value is None.
aggregationstringThe list of aggregation types (comma separated) to retrieve. Examples: average, minimum, maximum. Default value is None.
intervalstringThe 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. Default value is None.
metricnamesstringThe names of the metrics (comma separated) to retrieve. Limit 20 metrics. Default value is None.
metricnamespacestringMetric namespace where the metrics you want reside. Default value is None.
orderbystringThe aggregation to use for sorting results and the direction of the sort. Only one order can be specified. Examples: sum asc. Default value is None.
resultTypestringReduces the set of data collected. The syntax allowed depends on the operation. See the operation's description for details. Known values are: "Data" and "Metadata". Default value is None.
rollupbystringDimension 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. Default value is None.
timespanstringThe timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. Default value is None.
topintegerThe maximum number of records to retrieve per resource ID in the request. Valid only if filter is specified. Defaults to 10. Default value is None.

SELECT examples

Lists the metric data for a subscription. This API used the default ARM throttling limits _.

SELECT
cost,
interval,
namespace,
resourceregion,
timespan,
value
FROM azure.monitor.metrics
WHERE subscription_id = '{{ subscription_id }}' -- required
AND region = '{{ region }}' -- required
AND timespan = '{{ timespan }}'
AND interval = '{{ interval }}'
AND metricnames = '{{ metricnames }}'
AND aggregation = '{{ aggregation }}'
AND top = '{{ top }}'
AND orderby = '{{ orderby }}'
AND $filter = '{{ $filter }}'
AND resultType = '{{ resultType }}'
AND metricnamespace = '{{ metricnamespace }}'
AND AutoAdjustTimegrain = '{{ AutoAdjustTimegrain }}'
AND ValidateDimensions = '{{ ValidateDimensions }}'
AND rollupby = '{{ rollupby }}'
;

Lifecycle Methods

Lists the metric data for a subscription. Parameters can be specified on either query params or the body. This API used the default ARM throttling limits _.

EXEC azure.monitor.metrics.list_at_subscription_scope_post 
@subscription_id='{{ subscription_id }}' --required,
@region='{{ region }}' --required,
@timespan='{{ timespan }}',
@interval='{{ interval }}',
@metricnames='{{ metricnames }}',
@aggregation='{{ aggregation }}',
@top='{{ top }}',
@orderby='{{ orderby }}',
@$filter='{{ $filter }}',
@resultType='{{ resultType }}',
@metricnamespace='{{ metricnamespace }}',
@AutoAdjustTimegrain={{ AutoAdjustTimegrain }},
@ValidateDimensions={{ ValidateDimensions }},
@rollupby='{{ rollupby }}'
@@json=
'{
"timespan": "{{ timespan }}",
"interval": "{{ interval }}",
"metricNames": "{{ metricNames }}",
"aggregation": "{{ aggregation }}",
"filter": "{{ filter }}",
"top": {{ top }},
"orderBy": "{{ orderBy }}",
"rollUpBy": "{{ rollUpBy }}",
"resultType": "{{ resultType }}",
"metricNamespace": "{{ metricNamespace }}",
"autoAdjustTimegrain": {{ autoAdjustTimegrain }},
"validateDimensions": {{ validateDimensions }}
}'
;