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.
| Method | Request URI |
|---|---|
| GET | https://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:
| Property | Definition |
|---|---|
| name.value | Value name (rather than localized name, see get metric defintions) of a metric. |
| aggregationType | Aggregation type of a metric. Possible values are Total, Maximum, Minimum, and Average. |
| startTime | Earliest time for which metric data should be returned. |
| endTime | Latest time for which metric data should be returned. |
| timeGrain | Granularity 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 Expression | Description |
|---|---|
| $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 name | Type | Description |
|---|---|---|
| value | Complex Type | Array of JSON blobs where each blob is the metric data (values) returned for a particular metric. |
| data | Complex Type | JSON blob of metric data (values) for a particular metric. |
| timeStamp | String | Time stamp of a particular data point. |
| name | Complex Type | LocalizableString object containing the name and a localized value. |
| unit | String | Unit of measurement for this metric. |
Show: