Metrics - List At Subscription Scope
Lists the metric data for a subscription.
GET https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metrics?api-version=2023-10-01®ion={region}
GET https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metrics?api-version=2023-10-01®ion={region}×pan={timespan}&interval={interval}&metricnames={metricnames}&aggregation={aggregation}&top={top}&orderby={orderby}&$filter={$filter}&resultType={resultType}&metricnamespace={metricnamespace}&AutoAdjustTimegrain={AutoAdjustTimegrain}&ValidateDimensions={ValidateDimensions}&rollupby={rollupby}
URI Parameters
Name | In | Required | Type | Description |
---|---|---|---|---|
subscription
|
path | True |
string |
The ID of the target subscription. |
api-version
|
query | True |
string |
The API version to use for this operation. |
region
|
query | True |
string |
The region where the metrics you want reside. |
$filter
|
query |
string |
The $filter is used to reduce the set of metric data returned. |
|
aggregation
|
query |
string |
The list of aggregation types (comma separated) to retrieve. Examples: average, minimum, maximum |
|
Auto
|
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 |
|
result
|
query |
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. |
|
Validate
|
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 |
Successful request to get the list of metric values. |
|
Other Status Codes |
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 subscription level metric data |
Get subscription level metric metadata |
Get subscription level metric data
Sample request
GET https://management.azure.com/subscriptions/92d2a2d8-b514-432d-8cc9-a5f9272630d5/providers/Microsoft.Insights/metrics?api-version=2023-10-01®ion=westus2×pan=2021-06-08T19:00:00Z/2021-06-12T01:00:00Z&interval=PT6H&metricnames=Data Disk Max Burst IOPS&aggregation=count&top=10&orderby=count desc&$filter=LUN eq '0' and Microsoft.ResourceId eq '*'&metricnamespace=microsoft.compute/virtualmachines&AutoAdjustTimegrain=True&ValidateDimensions=False
Sample response
{
"cost": 4679,
"timespan": "2021-06-08T19:00:00Z/2021-06-12T01:00:00Z",
"interval": "PT6H",
"value": [
{
"id": "subscriptions/92d2a2d8-b514-432d-8cc9-a5f9272630d5/providers/Microsoft.Insights/metrics/Data Disk Max Burst IOPS",
"type": "Microsoft.Insights/metrics",
"name": {
"value": "Data Disk Max Burst IOPS",
"localizedValue": "Data Disk Max Burst IOPS"
},
"displayDescription": "Maximum IOPS Data Disk can achieve with bursting",
"unit": "Count",
"timeseries": [
{
"metadatavalues": [
{
"name": {
"value": "microsoft.resourceid",
"localizedValue": "microsoft.resourceid"
},
"value": "/subscriptions/92d2a2d8-b514-432d-8cc9-a5f9272630d5/resourceGroups/sas1/providers/Microsoft.Compute/virtualMachines/sas1-dev"
}
],
"data": [
{
"timeStamp": "2021-06-08T19:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-09T01:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-09T07:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-09T13:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-09T19:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-10T01:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-10T07:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-10T13:00:00Z",
"count": 413
},
{
"timeStamp": "2021-06-10T19:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-11T01:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-11T07:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-11T13:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-11T19:00:00Z",
"count": 72
}
]
},
{
"metadatavalues": [
{
"name": {
"value": "microsoft.resourceid",
"localizedValue": "microsoft.resourceid"
},
"value": "/subscriptions/92d2a2d8-b514-432d-8cc9-a5f9272630d5/resourceGroups/sas2/providers/Microsoft.Compute/virtualMachines/sas2-vm"
}
],
"data": [
{
"timeStamp": "2021-06-08T19:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-09T01:00:00Z",
"count": 133
},
{
"timeStamp": "2021-06-09T07:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-09T13:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-09T19:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-10T01:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-10T07:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-10T13:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-10T19:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-11T01:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-11T07:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-11T13:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-11T19:00:00Z",
"count": 72
}
]
},
{
"metadatavalues": [
{
"name": {
"value": "microsoft.resourceid",
"localizedValue": "microsoft.resourceid"
},
"value": "/subscriptions/92d2a2d8-b514-432d-8cc9-a5f9272630d5/resourceGroups/sas3/providers/Microsoft.Compute/virtualMachines/sas3-vm"
}
],
"data": [
{
"timeStamp": "2021-06-08T19:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-09T01:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-09T07:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-09T13:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-09T19:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-10T01:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-10T07:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-10T13:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-10T19:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-11T01:00:00Z",
"count": 78
},
{
"timeStamp": "2021-06-11T07:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-11T13:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-11T19:00:00Z",
"count": 72
}
]
},
{
"metadatavalues": [
{
"name": {
"value": "microsoft.resourceid",
"localizedValue": "microsoft.resourceid"
},
"value": "/subscriptions/92d2a2d8-b514-432d-8cc9-a5f9272630d5/resourceGroups/sas4/providers/Microsoft.Compute/virtualMachines/sas4-vm"
}
],
"data": [
{
"timeStamp": "2021-06-08T19:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-09T01:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-09T07:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-09T13:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-09T19:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-10T01:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-10T07:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-10T13:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-10T19:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-11T01:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-11T07:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-11T13:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-11T19:00:00Z",
"count": 72
}
]
},
{
"metadatavalues": [
{
"name": {
"value": "microsoft.resourceid",
"localizedValue": "microsoft.resourceid"
},
"value": "/subscriptions/92d2a2d8-b514-432d-8cc9-a5f9272630d5/resourceGroups/sas5/providers/Microsoft.Compute/virtualMachines/sas5-vm-asc"
}
],
"data": [
{
"timeStamp": "2021-06-08T19:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-09T01:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-09T07:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-09T13:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-09T19:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-10T01:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-10T07:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-10T13:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-10T19:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-11T01:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-11T07:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-11T13:00:00Z",
"count": 72
},
{
"timeStamp": "2021-06-11T19:00:00Z",
"count": 72
}
]
}
],
"errorCode": "Success"
}
],
"namespace": "microsoft.compute/virtualmachines",
"resourceregion": "westus2"
}
{
"error": {
"code": "BadRequest",
"message": "Missing required region params"
}
}
Get subscription level metric metadata
Sample request
GET https://management.azure.com/subscriptions/92d2a2d8-b514-432d-8cc9-a5f9272630d5/providers/Microsoft.Insights/metrics?api-version=2023-10-01®ion=westus2×pan=2021-06-10T02:23:16.129Z/2021-06-12T02:23:16.129Z&metricnames=Data Disk Max Burst IOPS&$filter=LUN eq '0'&metricnamespace=microsoft.compute/virtualmachines
Sample response
{
"timespan": "2021-06-10T02:23:16Z/2021-06-12T02:23:16Z",
"interval": "PT1M",
"value": [
{
"id": "subscriptions/92d2a2d8-b514-432d-8cc9-a5f9272630d5/providers/Microsoft.Insights/metrics/Data Disk Read Bytes/sec",
"type": "Microsoft.Insights/metrics",
"name": {
"value": "Data Disk Read Bytes/sec",
"localizedValue": "Data Disk Read Bytes/Sec"
},
"displayDescription": "Bytes/Sec read from a single disk during monitoring period",
"unit": "BytesPerSecond",
"timeseries": [
{
"metadatavalues": [
{
"name": {
"value": "lun",
"localizedValue": "lun"
},
"value": "0"
}
]
},
{
"metadatavalues": [
{
"name": {
"value": "lun",
"localizedValue": "lun"
},
"value": "1"
}
]
}
]
}
],
"namespace": "microsoft.compute/virtualmachines",
"resourceregion": "westus2"
}
Definitions
Name | Description |
---|---|
Error |
The resource management error additional info. |
Error |
Error Response |
Error |
Error Response |
Localizable |
The localizable string class. |
Metadata |
Represents a metric metadata value. |
Metric |
The result data of a query. |
Metric |
Reduces the set of data collected. The syntax allowed depends on the operation. See the operation's description for details. |
Metric |
The unit of the metric. |
Metric |
Represents a metric value. |
Response |
The response to a metrics query. |
Time |
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. |
ErrorContract
Error Response
Name | Type | Description |
---|---|---|
error |
Error Response |
ErrorResponse
Error Response
Name | Type | Description |
---|---|---|
additionalInfo |
The error additional info. |
|
code |
string |
The error code. |
details |
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 |
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 |
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. |
MetricResultType
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 |
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. |
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. |