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.

timespan
query
  • string

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

interval
query
  • string
duration

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

metricnames
query
  • string

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

aggregation
query
  • string

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

top
query
  • integer
int32

The maximum number of records to retrieve. Valid only if $filter is specified. Defaults to 10.

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.

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

resultType
query

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

api-version
query True
  • string

Client Api Version.

metricnamespace
query
  • string

Metric namespace to query metric definitions for.

Responses

Name Type Description
200 OK

Successful request to get the list of metric values.

Other Status Codes

Error response describing why the operation failed.

Examples

Get Metric for data
Get Metric for metadata

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",
      "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"
      },
      "unit": "Bytes",
      "timeseries": [
        {
          "metadatavalues": [
            {
              "name": {
                "value": "blobtype",
                "localizedValue": "blobtype"
              },
              "value": "BlockBlob"
            }
          ]
        },
        {
          "metadatavalues": [
            {
              "name": {
                "value": "blobtype",
                "localizedValue": "blobtype"
              },
              "value": "PageBlob"
            }
          ]
        }
      ]
    }
  ]
}

Definitions

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.

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.

Unit

the unit of the metric.

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

the name of the metadata.

value
  • string

the value of the metadata.

Metric

The result data of a query.

Name Type Description
id
  • string

the metric Id.

name

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

timeseries

the time series returned when a data query is performed.

type
  • string

the resource type of the metric resource.

unit

the unit of the metric.

MetricValue

Represents a metric value.

Name Type Description
average
  • number

the average value in the time range.

count
  • integer

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 cost of the query, for data case.

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 been queried

resourceregion
  • string

The region of the resource been queried for metrics.

timespan
  • string

The timespan for which the data was retrieved. Its value consists of two datatimes concatenated, separated by '/'. This may be adjusted in the future and returned back from what was originally requested.

value

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

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

metadatavalues

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

Unit

the unit of the metric.

Name Type Description
ByteSeconds
  • string
Bytes
  • string
BytesPerSecond
  • string
Count
  • string
CountPerSecond
  • string
MilliSeconds
  • string
Percent
  • string
Seconds
  • string
Unspecified
  • string