Metrics - List

Lists the metric values for a resource.

GET https://management.azure.com/{resourceUri}/providers/Microsoft.Insights/metrics?api-version=2023-10-01
GET https://management.azure.com/{resourceUri}/providers/Microsoft.Insights/metrics?timespan={timespan}&interval={interval}&metricnames={metricnames}&aggregation={aggregation}&top={top}&orderby={orderby}&$filter={$filter}&resultType={resultType}&api-version=2023-10-01&metricnamespace={metricnamespace}&AutoAdjustTimegrain={AutoAdjustTimegrain}&ValidateDimensions={ValidateDimensions}&rollupby={rollupby}

URI Parameters

Name In Required Type Description
resourceUri
path True

string

The identifier of the resource.

api-version
query True

string

The API version to use for this operation.

$filter
query

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 ‘.

aggregation
query

string

The list of aggregation types (comma separated) to retrieve. Examples: average, minimum, maximum

AutoAdjustTimegrain
query

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.

interval
query

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

metricnames
query

string

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

metricnamespace
query

string

Metric namespace where the metrics you want reside.

orderby
query

string

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

resultType
query

ResultType

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

rollupby
query

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.

timespan
query

string

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

top
query

integer

int32

The maximum number of records to retrieve per resource ID in the request. Valid only if filter is specified. Defaults to 10.

ValidateDimensions
query

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.

Responses

Name Type Description
200 OK

Response

Successful request to get the list of metric values.

Other Status Codes

ErrorResponse

Error response describing why the operation failed.

Security

azure_auth

Azure Active Directory OAuth2 Flow

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize

Scopes

Name Description
user_impersonation impersonate your user account

Examples

Get Metric for data
Get Metric for metadata
Get Metric with error

Get Metric for data

Sample request

GET https://management.azure.com/subscriptions/1f3fa6d2-851c-4a91-9087-1a050f3a9c38/resourceGroups/todking/providers/Microsoft.Storage/storageAccounts/tkfileserv/blobServices/default/providers/Microsoft.Insights/metrics?timespan=2021-04-20T09:00:00.000Z/2021-04-20T14:00:00.000Z&interval=PT6H&metricnames=BlobCount,BlobCapacity&aggregation=average,minimum,maximum&top=5&orderby=average asc&$filter=Tier eq '*'&api-version=2023-10-01&metricnamespace=Microsoft.Storage/storageAccounts/blobServices&AutoAdjustTimegrain=True&ValidateDimensions=False

Sample response

{
  "cost": 598,
  "timespan": "2021-04-20T09:00:00Z/2021-04-20T14:00:00Z",
  "interval": "PT1H",
  "value": [
    {
      "id": "/subscriptions/1f3fa6d2-851c-4a91-9087-1a050f3a9c38/resourceGroups/todking/providers/Microsoft.Storage/storageAccounts/tkfileserv/blobServices/default/providers/Microsoft.Insights/metrics/BlobCount",
      "type": "Microsoft.Insights/metrics",
      "name": {
        "value": "BlobCount",
        "localizedValue": "Blob Count"
      },
      "displayDescription": "The number of blob objects stored in the storage account.",
      "unit": "Count",
      "timeseries": [
        {
          "metadatavalues": [
            {
              "name": {
                "value": "tier",
                "localizedValue": "tier"
              },
              "value": "Hot"
            }
          ],
          "data": [
            {
              "timeStamp": "2021-04-20T09:00:00Z",
              "average": 7,
              "minimum": 7,
              "maximum": 7
            },
            {
              "timeStamp": "2021-04-20T10:00:00Z",
              "average": 7,
              "minimum": 7,
              "maximum": 7
            },
            {
              "timeStamp": "2021-04-20T11:00:00Z",
              "average": 7,
              "minimum": 7,
              "maximum": 7
            },
            {
              "timeStamp": "2021-04-20T12:00:00Z",
              "average": 7,
              "minimum": 7,
              "maximum": 7
            },
            {
              "timeStamp": "2021-04-20T13:00:00Z",
              "average": 7,
              "minimum": 7,
              "maximum": 7
            }
          ]
        },
        {
          "metadatavalues": [
            {
              "name": {
                "value": "tier",
                "localizedValue": "tier"
              },
              "value": "Standard"
            }
          ],
          "data": [
            {
              "timeStamp": "2021-04-20T09:00:00Z",
              "average": 2,
              "minimum": 2,
              "maximum": 2
            },
            {
              "timeStamp": "2021-04-20T10:00:00Z",
              "average": 2,
              "minimum": 2,
              "maximum": 2
            },
            {
              "timeStamp": "2021-04-20T11:00:00Z",
              "average": 2,
              "minimum": 2,
              "maximum": 2
            },
            {
              "timeStamp": "2021-04-20T12:00:00Z",
              "average": 2,
              "minimum": 2,
              "maximum": 2
            },
            {
              "timeStamp": "2021-04-20T13:00:00Z",
              "average": 2,
              "minimum": 2,
              "maximum": 2
            }
          ]
        },
        {
          "metadatavalues": [
            {
              "name": {
                "value": "tier",
                "localizedValue": "tier"
              },
              "value": "Cool"
            }
          ],
          "data": [
            {
              "timeStamp": "2021-04-20T09:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T10:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T11:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T12:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T13:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            }
          ]
        },
        {
          "metadatavalues": [
            {
              "name": {
                "value": "tier",
                "localizedValue": "tier"
              },
              "value": "Archive"
            }
          ],
          "data": [
            {
              "timeStamp": "2021-04-20T09:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T10:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T11:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T12:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T13:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            }
          ]
        },
        {
          "metadatavalues": [
            {
              "name": {
                "value": "tier",
                "localizedValue": "tier"
              },
              "value": "Untiered"
            }
          ],
          "data": [
            {
              "timeStamp": "2021-04-20T09:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T10:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T11:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T12:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T13:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            }
          ]
        }
      ],
      "errorCode": "Success"
    },
    {
      "id": "/subscriptions/1f3fa6d2-851c-4a91-9087-1a050f3a9c38/resourceGroups/todking/providers/Microsoft.Storage/storageAccounts/tkfileserv/blobServices/default/providers/Microsoft.Insights/metrics/BlobCapacity",
      "type": "Microsoft.Insights/metrics",
      "name": {
        "value": "BlobCapacity",
        "localizedValue": "Blob Capacity"
      },
      "displayDescription": "The amount of storage used by the storage account’s Blob service in bytes.",
      "unit": "Bytes",
      "timeseries": [
        {
          "metadatavalues": [
            {
              "name": {
                "value": "tier",
                "localizedValue": "tier"
              },
              "value": "Standard"
            }
          ],
          "data": [
            {
              "timeStamp": "2021-04-20T09:00:00Z",
              "average": 621492,
              "minimum": 621492,
              "maximum": 621492
            },
            {
              "timeStamp": "2021-04-20T10:00:00Z",
              "average": 621492,
              "minimum": 621492,
              "maximum": 621492
            },
            {
              "timeStamp": "2021-04-20T11:00:00Z",
              "average": 621492,
              "minimum": 621492,
              "maximum": 621492
            },
            {
              "timeStamp": "2021-04-20T12:00:00Z",
              "average": 621492,
              "minimum": 621492,
              "maximum": 621492
            },
            {
              "timeStamp": "2021-04-20T13:00:00Z",
              "average": 621492,
              "minimum": 621492,
              "maximum": 621492
            }
          ]
        },
        {
          "metadatavalues": [
            {
              "name": {
                "value": "tier",
                "localizedValue": "tier"
              },
              "value": "Hot"
            }
          ],
          "data": [
            {
              "timeStamp": "2021-04-20T09:00:00Z",
              "average": 4733,
              "minimum": 4733,
              "maximum": 4733
            },
            {
              "timeStamp": "2021-04-20T10:00:00Z",
              "average": 4733,
              "minimum": 4733,
              "maximum": 4733
            },
            {
              "timeStamp": "2021-04-20T11:00:00Z",
              "average": 4733,
              "minimum": 4733,
              "maximum": 4733
            },
            {
              "timeStamp": "2021-04-20T12:00:00Z",
              "average": 4733,
              "minimum": 4733,
              "maximum": 4733
            },
            {
              "timeStamp": "2021-04-20T13:00:00Z",
              "average": 4733,
              "minimum": 4733,
              "maximum": 4733
            }
          ]
        },
        {
          "metadatavalues": [
            {
              "name": {
                "value": "tier",
                "localizedValue": "tier"
              },
              "value": "Archive"
            }
          ],
          "data": [
            {
              "timeStamp": "2021-04-20T09:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T10:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T11:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T12:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T13:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            }
          ]
        },
        {
          "metadatavalues": [
            {
              "name": {
                "value": "tier",
                "localizedValue": "tier"
              },
              "value": "Untiered"
            }
          ],
          "data": [
            {
              "timeStamp": "2021-04-20T09:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T10:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T11:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T12:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T13:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            }
          ]
        },
        {
          "metadatavalues": [
            {
              "name": {
                "value": "tier",
                "localizedValue": "tier"
              },
              "value": "Cool"
            }
          ],
          "data": [
            {
              "timeStamp": "2021-04-20T09:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T10:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T11:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T12:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            },
            {
              "timeStamp": "2021-04-20T13:00:00Z",
              "average": 0,
              "minimum": 0,
              "maximum": 0
            }
          ]
        }
      ],
      "errorCode": "Success"
    }
  ],
  "namespace": "microsoft.storage/storageaccounts/blobservices",
  "resourceregion": "westus2"
}

Get Metric for metadata

Sample request

GET https://management.azure.com/subscriptions/1f3fa6d2-851c-4a91-9087-1a050f3a9c38/resourceGroups/todking/providers/Microsoft.Storage/storageAccounts/tkfileserv/blobServices/default/providers/Microsoft.Insights/metrics?timespan=2017-04-14T02:20:00Z/2017-04-14T04:20:00Z&$filter=Tier eq '*'&api-version=2023-10-01&metricnamespace=Microsoft.Storage/storageAccounts/blobServices

Sample response

{
  "timespan": "2021-04-15T02:18:00Z/2021-04-22T02:18:00Z",
  "interval": "PT1H",
  "value": [
    {
      "id": "/subscriptions/1f3fa6d2-851c-4a91-9087-1a050f3a9c38/resourceGroups/todking/providers/Microsoft.Storage/storageAccounts/tkfileserv/blobServices/default/providers/Microsoft.Insights/metrics/BlobCount",
      "type": "Microsoft.Insights/metrics",
      "name": {
        "value": "BlobCount",
        "localizedValue": "Blob Count"
      },
      "displayDescription": "The number of blob objects stored in the storage account.",
      "unit": "Count",
      "timeseries": [
        {
          "metadatavalues": [
            {
              "name": {
                "value": "tier",
                "localizedValue": "tier"
              },
              "value": "Cool"
            }
          ]
        },
        {
          "metadatavalues": [
            {
              "name": {
                "value": "tier",
                "localizedValue": "tier"
              },
              "value": "Archive"
            }
          ]
        },
        {
          "metadatavalues": [
            {
              "name": {
                "value": "tier",
                "localizedValue": "tier"
              },
              "value": "Standard"
            }
          ]
        },
        {
          "metadatavalues": [
            {
              "name": {
                "value": "tier",
                "localizedValue": "tier"
              },
              "value": "Untiered"
            }
          ]
        },
        {
          "metadatavalues": [
            {
              "name": {
                "value": "tier",
                "localizedValue": "tier"
              },
              "value": "Hot"
            }
          ]
        }
      ]
    }
  ],
  "namespace": "microsoft.storage/storageaccounts/blobservices",
  "resourceregion": "westus2"
}

Get Metric with error

Sample request

GET https://management.azure.com/subscriptions/ac41e21f-afd6-4a79-8070-f01eba278f97/resourceGroups/todking/providers/Microsoft.DocumentDb/databaseAccounts/tk-cosmos-mongo/providers/Microsoft.Insights/metrics?timespan=2021-06-07T21:51:00Z/2021-06-08T01:51:00Z&interval=FULL&metricnames=MongoRequestsCount,MongoRequests&aggregation=average&api-version=2023-10-01&metricnamespace=microsoft.documentdb/databaseaccounts&AutoAdjustTimegrain=True&ValidateDimensions=False

Sample response

{
  "cost": 239,
  "timespan": "2021-06-07T21:51:00Z/2021-06-08T01:51:00Z",
  "interval": "PT4H",
  "value": [
    {
      "id": "/subscriptions/ac41e21f-afd6-4a79-8070-f01eba278f97/resourceGroups/todking/providers/Microsoft.DocumentDb/databaseAccounts/tk-cosmos-mongo/providers/Microsoft.Insights/metrics/MongoRequestsCount",
      "type": "Microsoft.Insights/metrics",
      "name": {
        "value": "MongoRequestsCount",
        "localizedValue": "(deprecated) Mongo Request Rate"
      },
      "unit": "CountPerSecond",
      "timeseries": [],
      "errorMessage": "Sampling type is not found. Metric:CosmosDBCustomer,AzureMonitor,MongoRequests, SamplingType:NullableAverage.",
      "errorCode": "InvalidSamplingType"
    },
    {
      "id": "/subscriptions/ac41e21f-afd6-4a79-8070-f01eba278f97/resourceGroups/todking/providers/Microsoft.DocumentDb/databaseAccounts/tk-cosmos-mongo/providers/Microsoft.Insights/metrics/MongoRequests",
      "type": "Microsoft.Insights/metrics",
      "name": {
        "value": "MongoRequests",
        "localizedValue": "Mongo Requests"
      },
      "displayDescription": "Number of Mongo Requests Made",
      "unit": "Count",
      "timeseries": [
        {
          "metadatavalues": [],
          "data": [
            {
              "timeStamp": "2021-06-07T21:51:00Z",
              "average": 0
            }
          ]
        }
      ],
      "errorCode": "Success"
    }
  ],
  "namespace": "microsoft.documentdb/databaseaccounts",
  "resourceregion": "westus2"
}

Definitions

Name Description
ErrorAdditionalInfo

The resource management error additional info.

ErrorResponse

Error Response

LocalizableString

The localizable string class.

MetadataValue

Represents a metric metadata value.

Metric

The result data of a query.

MetricUnit

The unit of the metric.

MetricValue

Represents a metric value.

Response

The response to a metrics query.

ResultType

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

TimeSeriesElement

A time series result type. The discriminator value is always TimeSeries in this case.

ErrorAdditionalInfo

The resource management error additional info.

Name Type Description
info

object

The additional info.

type

string

The additional info type.

ErrorResponse

Error Response

Name Type Description
additionalInfo

ErrorAdditionalInfo[]

The error additional info.

code

string

The error code.

details

ErrorResponse[]

The error details.

message

string

The error message.

target

string

The error target.

LocalizableString

The localizable string class.

Name Type Description
localizedValue

string

The display name.

value

string

The invariant value.

MetadataValue

Represents a metric metadata value.

Name Type Description
name

LocalizableString

The name of the metadata.

value

string

The value of the metadata.

Metric

The result data of a query.

Name Type Description
displayDescription

string

Detailed description of this metric.

errorCode

string

'Success' or the error details on query failures for this metric.

errorMessage

string

Error message encountered querying this specific metric.

id

string

The metric Id.

name

LocalizableString

The name and the display name of the metric, i.e. it is localizable string.

timeseries

TimeSeriesElement[]

The time series returned when a data query is performed.

type

string

The resource type of the metric resource.

unit

MetricUnit

The unit of the metric.

MetricUnit

The unit of the metric.

Name Type Description
BitsPerSecond

string

Rate unit of binary digits per second.

ByteSeconds

string

Unit of data transfer or storage. It is the size of the data in bytes multiplied by the time it takes to transfer or store the data in seconds.

Bytes

string

Unit of memory in bytes.

BytesPerSecond

string

Rate unit of memory in bytes per second.

Cores

string

Unit of processing power.

Count

string

Unit of raw quantity.

CountPerSecond

string

Rate unit of raw quantity per second.

MilliCores

string

Unit of processing power in 1/1000th of a CPU core.

MilliSeconds

string

Unit of time in 1/1000th of a second.

NanoCores

string

Unit of processing power in one billionth of a CPU core.

Percent

string

Percentage unit.

Seconds

string

Unit of time in seconds.

Unspecified

string

No specified unit.

MetricValue

Represents a metric value.

Name Type Description
average

number

The average value in the time range.

count

number

The number of samples in the time range. Can be used to determine the number of values that contributed to the average value.

maximum

number

The greatest value in the time range.

minimum

number

The least value in the time range.

timeStamp

string

The timestamp for the metric value in ISO 8601 format.

total

number

The sum of all of the values in the time range.

Response

The response to a metrics query.

Name Type Description
cost

number

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.

value

Metric[]

The value of the collection.

ResultType

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

Name Type Description
Data

string

Metadata

string

TimeSeriesElement

A time series result type. The discriminator value is always TimeSeries in this case.

Name Type Description
data

MetricValue[]

An array of data points representing the metric values. This is only returned if a result type of data is specified.

metadatavalues

MetadataValue[]

The metadata values returned if $filter was specified in the call.