swagger: '2.0'
info:
title: Microsoft Azure Azure Monitor Metrics Data API
description: Provides APIs for getting the metric data for Azure resources.
version: '2023-10-01'
host: management.azure.com
schemes:
- https
consumes:
- application/json
produces:
- application/json
security:
- azure_auth:
- user_impersonation
securityDefinitions:
azure_auth:
type: oauth2
authorizationUrl: https://login.microsoftonline.com/common/oauth2/authorize
flow: implicit
description: Azure Active Directory OAuth2 Flow
scopes:
user_impersonation: impersonate your user account
paths:
/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metrics:
get:
tags:
- Metrics
operationId: microsoftAzureMetricsListatsubscriptionscope
description: '**Lists the metric data for a subscription**.'
parameters:
- $ref: >-
../../../../../common-types/resource-management/v2/types.json#/parameters/SubscriptionIdParameter
- $ref: >-
../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter
- $ref: >-
../../../../common-types/v2/commonMonitoringTypes.json#/parameters/RegionParameter
- $ref: '#/parameters/TimespanParameter'
- $ref: '#/parameters/IntervalParameter'
- $ref: '#/parameters/MetricNamesParameter'
- $ref: >-
../../../../common-types/v2/commonMonitoringTypes.json#/parameters/AggregationsParameter
- $ref: >-
../../../../common-types/v2/commonMonitoringTypes.json#/parameters/TopParameter
- $ref: >-
../../../../common-types/v2/commonMonitoringTypes.json#/parameters/OrderByParameter
- $ref: '#/parameters/FilterParameter'
- $ref: '#/parameters/SubscriptionScopeResultTypeParameter'
- $ref: >-
../../../../common-types/v2/commonMonitoringTypes.json#/parameters/MetricNamespaceParameter
- $ref: '#/parameters/AutoAdjustTimegrain'
- $ref: '#/parameters/ValidateDimensions'
- $ref: >-
../../../../common-types/v2/commonMonitoringTypes.json#/parameters/RollUpByParameter
responses:
'200':
description: Successful request to get the list of metric values.
schema:
$ref: '#/definitions/Response'
default:
description: Error response describing why the operation failed.
schema:
$ref: >-
../../../../common-types/v2/commonMonitoringTypes.json#/definitions/ErrorContract
x-ms-odata: >-
../../../../common-types/v2/commonMonitoringTypes.json#/definitions/MetadataValue
x-ms-examples:
Get subscription level metric data:
$ref: ./examples/GetMultiResourceMetric.json
Get subscription level metric metadata:
$ref: ./examples/GetMultiResourceMetricMetadata.json
summary: Microsoft Azure Get Subscriptions Subscriptionid Providers Microsoft Insights Metrics
post:
tags:
- Metrics
operationId: microsoftAzureMetricsListatsubscriptionscopepost
description: >-
**Lists the metric data for a subscription**. Parameters can be
specified on either query params or the body.
parameters:
- $ref: >-
../../../../../common-types/resource-management/v2/types.json#/parameters/SubscriptionIdParameter
- $ref: >-
../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter
- $ref: >-
../../../../common-types/v2/commonMonitoringTypes.json#/parameters/RegionParameter
- $ref: '#/parameters/TimespanParameter'
- $ref: '#/parameters/IntervalParameter'
- $ref: '#/parameters/MetricNamesParameter'
- $ref: >-
../../../../common-types/v2/commonMonitoringTypes.json#/parameters/AggregationsParameter
- $ref: >-
../../../../common-types/v2/commonMonitoringTypes.json#/parameters/TopParameter
- $ref: >-
../../../../common-types/v2/commonMonitoringTypes.json#/parameters/OrderByParameter
- $ref: '#/parameters/FilterParameter'
- $ref: '#/parameters/SubscriptionScopeResultTypeParameter'
- $ref: >-
../../../../common-types/v2/commonMonitoringTypes.json#/parameters/MetricNamespaceParameter
- $ref: '#/parameters/AutoAdjustTimegrain'
- $ref: '#/parameters/ValidateDimensions'
- $ref: >-
../../../../common-types/v2/commonMonitoringTypes.json#/parameters/RollUpByParameter
- in: body
name: body
description: Parameters serialized in the body
schema:
$ref: '#/definitions/SubscriptionScopeMetricsRequestBodyParameters'
responses:
'200':
description: Successful request to get the list of metric values.
schema:
$ref: '#/definitions/Response'
default:
description: Error response describing why the operation failed.
schema:
$ref: >-
../../../../common-types/v2/commonMonitoringTypes.json#/definitions/ErrorContract
x-ms-odata: >-
../../../../common-types/v2/commonMonitoringTypes.json#/definitions/MetadataValue
x-ms-examples:
Post request for subscription level metric data:
$ref: ./examples/GetMultiResourceMetric.json
Post request for subscription level metric data using body params:
$ref: ./examples/PostMultiResourceMetricBody.json
Post request for subscription level metric metadata:
$ref: ./examples/GetMultiResourceMetricMetadata.json
summary: Microsoft Azure Post Subscriptions Subscriptionid Providers Microsoft Insights Metrics
/{resourceUri}/providers/Microsoft.Insights/metrics:
get:
tags:
- Metrics
operationId: microsoftAzureMetricsList
description: '**Lists the metric values for a resource**.'
parameters:
- $ref: >-
../../../../common-types/v2/commonMonitoringTypes.json#/parameters/ResourceUriParameter
- $ref: '#/parameters/TimespanParameter'
- $ref: '#/parameters/IntervalParameter'
- $ref: '#/parameters/MetricNamesParameter'
- $ref: >-
../../../../common-types/v2/commonMonitoringTypes.json#/parameters/AggregationsParameter
- $ref: >-
../../../../common-types/v2/commonMonitoringTypes.json#/parameters/TopParameter
- $ref: >-
../../../../common-types/v2/commonMonitoringTypes.json#/parameters/OrderByParameter
- $ref: '#/parameters/FilterParameter'
- $ref: '#/parameters/ResultTypeParameter'
- $ref: >-
../../../../../common-types/resource-management/v2/types.json#/parameters/ApiVersionParameter
- $ref: >-
../../../../common-types/v2/commonMonitoringTypes.json#/parameters/MetricNamespaceParameter
- $ref: '#/parameters/AutoAdjustTimegrain'
- $ref: '#/parameters/ValidateDimensions'
- $ref: >-
../../../../common-types/v2/commonMonitoringTypes.json#/parameters/RollUpByParameter
responses:
'200':
description: Successful request to get the list of metric values.
schema:
$ref: '#/definitions/Response'
default:
description: Error response describing why the operation failed.
schema:
$ref: >-
../../../../../common-types/resource-management/v1/types.json#/definitions/ErrorResponse
x-ms-odata: >-
../../../../common-types/v2/commonMonitoringTypes.json#/definitions/MetadataValue
x-ms-examples:
Get Metric for data:
$ref: ./examples/GetMetric.json
Get Metric for metadata:
$ref: ./examples/GetMetricMetadata.json
Get Metric with error:
$ref: ./examples/GetMetricError.json
summary: Microsoft Azure Get Resourceuri Providers Microsoft Insights Metrics
definitions:
SubscriptionScopeMetricsRequestBodyParameters:
description: >-
Query parameters can also be specified in the body, specifying the same
parameter in both the body and query parameters will result in an error.
type: object
properties:
timespan:
description: >-
The timespan of the query. It is a string with the following format
'startDateTime_ISO/endDateTime_ISO'.
type: string
interval:
description: >-
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*
type: string
metricNames:
description: The names of the metrics (comma separated) to retrieve.
type: string
aggregation:
description: The list of aggregation types (comma separated) to retrieve.
type: string
filter:
description: >-
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 ‘*’**.
type: string
top:
description: |-
The maximum number of records to retrieve.
Valid only if $filter is specified.
Defaults to 10.
type: integer
format: int32
orderBy:
description: >-
The aggregation to use for sorting results and the direction of the
sort.
Only one order can be specified.
Examples: sum asc.
type: string
rollUpBy:
description: >-
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.
type: string
resultType:
description: >-
Reduces the set of data collected. The syntax allowed depends on the
operation. See the operation's description for details.
type: string
enum:
- Data
- Metadata
x-ms-enum:
name: MetricResultType
modelAsString: true
metricNamespace:
description: Metric namespace where the metrics you want reside.
type: string
autoAdjustTimegrain:
description: >-
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.
type: boolean
validateDimensions:
description: >-
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.
type: boolean
Response:
type: object
description: The response to a metrics query.
properties:
cost:
type: number
format: int32
minimum: 0
description: The integer value representing the relative cost of the query.
timespan:
type: string
description: >-
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.
interval:
type: string
description: >-
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:
type: string
description: The namespace of the metrics being queried
resourceregion:
type: string
description: The region of the resource being queried for metrics.
value:
type: array
items:
$ref: >-
../../../../common-types/v2/commonMonitoringTypes.json#/definitions/Metric
description: The value of the collection.
required:
- timespan
- value
parameters:
TimespanParameter:
name: timespan
in: query
required: false
type: string
description: >-
The timespan of the query. It is a string with the following format
'startDateTime_ISO/endDateTime_ISO'.
x-ms-parameter-location: method
IntervalParameter:
name: interval
in: query
required: false
type: string
description: >-
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*
x-ms-parameter-location: method
MetricNamesParameter:
name: metricnames
in: query
required: false
type: string
description: The names of the metrics (comma separated) to retrieve.
x-ms-parameter-location: method
FilterParameter:
name: $filter
in: query
type: string
description: >-
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 ‘*’**.
required: false
x-ms-parameter-location: method
SubscriptionScopeResultTypeParameter:
name: resultType
in: query
type: string
enum:
- Data
- Metadata
x-ms-enum:
name: MetricResultType
modelAsString: true
description: >-
Reduces the set of data collected. The syntax allowed depends on the
operation. See the operation's description for details.
x-ms-parameter-location: method
required: false
ResultTypeParameter:
name: resultType
in: query
type: string
enum:
- Data
- Metadata
x-ms-enum:
name: ResultType
modelAsString: false
description: >-
Reduces the set of data collected. The syntax allowed depends on the
operation. See the operation's description for details.
x-ms-parameter-location: method
required: false
AutoAdjustTimegrain:
name: AutoAdjustTimegrain
in: query
required: false
type: boolean
description: >-
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.
x-ms-parameter-location: method
ValidateDimensions:
name: ValidateDimensions
in: query
required: false
type: boolean
description: >-
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.
x-ms-parameter-location: method
tags:
- name: Metrics