Metrics - List

Lists the metric values for a resource.

GET https://management.azure.com/{resourceUri}/providers/Microsoft.Insights/metrics?api-version=2018-01-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=2018-01-01&metricnamespace={metricnamespace}

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 ''. Special case: When dimension name or dimension value uses round brackets. Eg: When dimension name is dim (test) 1 Instead of using $filter= "dim (test) 1 eq '' " use **$filter= "dim %2528test%2529 1 eq '' "** When dimension name is dim (test) 3 and dimension value is dim3 (test) val Instead of using $filter= "dim (test) 3 eq 'dim3 (test) val' " use $filter= "dim %2528test%2529 3 eq 'dim3 %2528test%2529 val' "

aggregation
query

string

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

interval
query

string

duration

The interval (i.e. timegrain) of the query.

metricnames
query

string

The names of the metrics (comma separated) to retrieve. Special case: If a metricname itself has a comma in it then use %2 to indicate it. Eg: 'Metric,Name1' should be 'Metric%2Name1'

metricnamespace
query

string

Metric namespace to query metric definitions for.

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.

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. Valid only if $filter is specified. Defaults to 10.

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/b324c52b-4073-4807-93af-e07d289c093e/resourceGroups/test/providers/Microsoft.Storage/storageAccounts/larryshoebox/blobServices/default/providers/Microsoft.Insights/metrics?timespan=2017-04-14T02:20:00Z/2017-04-14T04:20:00Z&interval=PT1M&aggregation=Average,count&top=3&orderby=Average asc&$filter=BlobType eq '*'&api-version=2018-01-01&metricnamespace=Microsoft.Storage/storageAccounts/blobServices

Sample Response

{
  "cost": 0,
  "timespan": "2017-04-14T02:20:00Z/2017-04-14T04:20:00Z",
  "interval": "PT1M",
  "namespace": "Microsoft.Storage/storageAccounts/blobServices",
  "resourceregion": "eastus2",
  "value": [
    {
      "id": "/subscriptions/b324c52b-4073-4807-93af-e07d289c093e/resourceGroups/test/providers/Microsoft.Storage/storageAccounts/larryshoebox/blobServices/default/providers/Microsoft.Insights/metrics/BlobCapacity",
      "type": "Microsoft.Insights/metrics",
      "displayDescription": "The amount of storage used by the storage account’s Blob service in bytes.",
      "name": {
        "value": "BlobCapacity",
        "localizedValue": "Blob Capacity"
      },
      "unit": "Bytes",
      "timeseries": [
        {
          "metadatavalues": [
            {
              "name": {
                "value": "blobtype",
                "localizedValue": "blobtype"
              },
              "value": "PageBlob"
            }
          ],
          "data": [
            {
              "timeStamp": "2017-04-14T02:20:00Z",
              "count": 0
            },
            {
              "timeStamp": "2017-04-14T02:21:00Z",
              "count": 0
            },
            {
              "timeStamp": "2017-04-14T02:22:00Z",
              "count": 0
            },
            {
              "timeStamp": "2017-04-14T02:23:00Z",
              "count": 1,
              "average": 0
            }
          ]
        },
        {
          "metadatavalues": [
            {
              "name": {
                "value": "blobtype",
                "localizedValue": "blobtype"
              },
              "value": "BlockBlob"
            }
          ],
          "data": [
            {
              "timeStamp": "2017-04-14T02:20:00Z",
              "count": 0
            },
            {
              "timeStamp": "2017-04-14T02:21:00Z",
              "count": 0
            },
            {
              "timeStamp": "2017-04-14T02:22:00Z",
              "count": 0
            },
            {
              "timeStamp": "2017-04-14T02:23:00Z",
              "count": 1,
              "average": 245
            }
          ]
        }
      ]
    }
  ]
}

Get Metric for metadata

Sample Request

GET https://management.azure.com/subscriptions/b324c52b-4073-4807-93af-e07d289c093e/resourceGroups/test/providers/Microsoft.Storage/storageAccounts/larryshoebox/blobServices/default/providers/Microsoft.Insights/metrics?timespan=2017-04-14T02:20:00Z/2017-04-14T04:20:00Z&interval=PT1M&aggregation=Average,count&top=3&orderby=Average asc&$filter=BlobType eq '*'&api-version=2018-01-01&metricnamespace=Microsoft.Storage/storageAccounts/blobServices

Sample Response

{
  "timespan": "2017-04-14T02:20:00Z/2017-04-14T04:20:00Z",
  "namespace": "Microsoft.Storage/storageAccounts/blobServices",
  "resourceregion": "eastus2",
  "value": [
    {
      "id": "/subscriptions/b324c52b-4073-4807-93af-e07d289c093e/resourceGroups/test/providers/Microsoft.Storage/storageAccounts/larryshoebox/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": "blobtype",
                "localizedValue": "blobtype"
              },
              "value": "BlockBlob"
            }
          ]
        },
        {
          "metadatavalues": [
            {
              "name": {
                "value": "blobtype",
                "localizedValue": "blobtype"
              },
              "value": "PageBlob"
            }
          ]
        }
      ]
    }
  ]
}

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=2018-01-01&metricnamespace=microsoft.documentdb/databaseaccounts

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
ErrorResponse

Describes the format of 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.

ErrorResponse

Describes the format of Error response.

Name Type Description
code

string

Error code

message

string

Error message indicating why the operation failed.

LocalizableString

The localizable string class.

Name Type Description
localizedValue

string

the locale specific value.

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

ByteSeconds

string

Bytes

string

BytesPerSecond

string

Cores

string

Count

string

CountPerSecond

string

MilliCores

string

MilliSeconds

string

NanoCores

string

Percent

string

Seconds

string

Unspecified

string

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. This may be adjusted in the future and returned back from what was originally requested. 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.