List metrics for a resource in Azure Monitor REST API

 

Updated: September 26, 2016

Returns a set of metrics for a particular resource.

See common parameters and header for headers and parameters that are used by all requests related to metrics.

MethodRequest URI
GEThttps://management.azure.com/{resource-id}/providers/microsoft.insights/metrics?api-version={api-version}&$filter={filter-expression}

Use {filter-expression} to reduce the set of metric data returned. Some common properties for this expression will be:

PropertyDefinition
name.valueValue name (rather than localized name, see get metric defintions) of a metric.
aggregationTypeAggregation type of a metric. Possible values are Total, Maximum, Minimum, and Average.
startTimeEarliest time for which metric data should be returned.
endTimeLatest time for which metric data should be returned.
timeGrainGranularity of the metric data returned in ISO 8601 duration format, eg "duration'PT1M'".

The filter expression uses these properties with comparison operators (eg. eq, gt, lt) and multiple expressions can be combined with parentheses and "and/or" operators. Here are some example filter expressions:

Filter ExpressionDescription
$filter=(name.value eq 'RunsSucceeded') and aggregationType eq 'Total' and startTime eq 2016-02-20 and endTime eq 2016-02-21 and timeGrain eq duration'PT1M'Returns total runs succeeded between 2/21/2016 and 6/1/2016 with 1 minute data granularity.
$filter=(name.value eq 'RunsSucceeded') and (aggregationType eq 'Total' or aggregationType eq 'Average') and startTime eq 2016-02-20 and endTime eq 2016-02-21 and timeGrain eq duration’PT1H’Returns total and average runs succeeded between 2/21/2016 and 6/1/2016 with 1 hour data granularity.
$filter=(name.value eq 'ActionsCompleted' or name.value eq 'RunsSucceeded') and (aggregationType eq 'Total' or aggregationType eq ‘Average’) and startTime eq 2016-02-20 and endTime eq 2016-02-21 and timeGrain eq duration'PT1M'Returns total and average actions completed and runs succeeded between 2/21/2016 and 6/1/2016 with 1 minute data granularity.

If no filter expression is defined, the first metric defined for that resource will be returned using the primary aggregation type in the metric defintion over a time period of the last hour.

Status code: 200

{
  "value": [
    {
      "data": [
        {
          "timeStamp": "2016-09-21T19:59:00Z",
          "total": 4.0
        },
        {
          "timeStamp": "2016-09-21T20:00:00Z"
        },
        {
          "timeStamp": "2016-09-21T20:01:00Z"
        },
        {
          "timeStamp": "2016-09-21T20:02:00Z",
          "total": 2.0
        }
      ],
      "name": {
        "value": "RunsStarted",
        "localizedValue": "Runs Started"
      },
      "unit": "Count"
    }
  ]
}

Element nameTypeDescription
valueComplex TypeArray of JSON blobs where each blob is the metric data (values) returned for a particular metric.
dataComplex TypeJSON blob of metric data (values) for a particular metric.
timeStampStringTime stamp of a particular data point.
nameComplex TypeLocalizableString object containing the name and a localized value.
unitStringUnit of measurement for this metric.
Show: