metrics
Creates, updates, deletes, gets or lists a metrics resource.
Overview
| Name | metrics |
| Type | Resource |
| Id | azure.monitor.metrics |
Fields
The following fields are returned by SELECT queries:
- list_at_subscription_scope
- list
| Name | Datatype | Description |
|---|---|---|
cost | integer | The integer value representing the relative cost of the query. |
interval | string | The 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. |
namespace | string | The namespace of the metrics being queried. |
resourceregion | string | The region of the resource being queried for metrics. |
timespan | string | The 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. |
value | array | The value of the collection. Required. |
| Name | Datatype | Description |
|---|---|---|
cost | integer | The integer value representing the relative cost of the query. |
interval | string | The 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. |
namespace | string | The namespace of the metrics being queried. |
resourceregion | string | The region of the resource being queried for metrics. |
timespan | string | The 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. |
value | array | The value of the collection. Required. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
list_at_subscription_scope | select | subscription_id, region | timespan, interval, metricnames, aggregation, top, orderby, $filter, resultType, metricnamespace, AutoAdjustTimegrain, ValidateDimensions, rollupby | Lists the metric data for a subscription. This API used the default ARM throttling limits _. |
list | select | resource_uri | timespan, interval, metricnames, aggregation, top, orderby, $filter, resultType, metricnamespace, AutoAdjustTimegrain, ValidateDimensions, rollupby | Lists the metric values for a resource. This API used the default ARM throttling limits _. |
list_at_subscription_scope_post | exec | subscription_id, region | timespan, interval, metricnames, aggregation, top, orderby, $filter, resultType, metricnamespace, AutoAdjustTimegrain, ValidateDimensions, rollupby | 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 _. |
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.
| Name | Datatype | Description |
|---|---|---|
region | string | The region where the metrics you want reside. Required. |
resource_uri | string | The fully qualified Azure Resource manager identifier of the resource. Required. |
subscription_id | string | |
$filter | string | 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 ‘’**. Default value is None. |
AutoAdjustTimegrain | boolean | 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. Default value is None. |
ValidateDimensions | boolean | 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. Default value is None. |
aggregation | string | The list of aggregation types (comma separated) to retrieve. Examples: average, minimum, maximum. Default value is None. |
interval | string | 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. Default value is None. |
metricnames | string | The names of the metrics (comma separated) to retrieve. Limit 20 metrics. Default value is None. |
metricnamespace | string | Metric namespace where the metrics you want reside. Default value is None. |
orderby | string | The 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. |
resultType | string | Reduces 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. |
rollupby | string | 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. Default value is None. |
timespan | string | The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. Default value is None. |
top | integer | The 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
- list_at_subscription_scope
- list
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 }}'
;
Lists the metric values for a resource. This API used the default ARM throttling limits _.
SELECT
cost,
interval,
namespace,
resourceregion,
timespan,
value
FROM azure.monitor.metrics
WHERE resource_uri = '{{ resource_uri }}' -- 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
- list_at_subscription_scope_post
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 }}
}'
;