Metrics - Get Multiple
Retrieve metric data
Gets metric values for multiple metrics
POST https://api.applicationinsights.io/v1/apps/{appId}/metrics
URI Parameters
Name | In | Required | Type | Description |
---|---|---|---|---|
app
|
path | True |
string |
ID of the application. This is Application ID from the API Access settings blade in the Azure portal. |
Request Body
Name | Type | Description |
---|---|---|
body |
The batched metrics query. |
Responses
Name | Type | Description |
---|---|---|
200 OK |
Successful response |
|
Other Status Codes |
An error response object. |
Security
oauth2
Connect to Azure Application Insights API
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize?resource=https%3A%2F%2Fapi.applicationinsights.io
Scopes
Name | Description |
---|---|
user_impersonation | impersonate your user account |
Examples
postMetric
Sample request
POST https://api.applicationinsights.io/v1/apps/DEMO_APP/metrics
[
{
"id": "failed",
"parameters": {
"metricId": "requests/failed",
"timespan": "P2D",
"interval": "P1D"
}
},
{
"id": "count",
"parameters": {
"metricId": "requests/count",
"timespan": "P2D",
"interval": "P1D"
}
}
]
Sample response
[
{
"id": "failed",
"status": 200,
"body": {
"value": {
"start": "2018-01-22T19:59:12.488Z",
"end": "2018-01-24T19:59:12.488Z",
"interval": "P1D",
"segments": [
{
"start": "2018-01-22T19:59:12.488Z",
"end": "2018-01-23T00:00:00.000Z",
"requests/failed": {
"sum": 277
}
},
{
"start": "2018-01-23T00:00:00.000Z",
"end": "2018-01-24T00:00:00.000Z",
"requests/failed": {
"sum": 1599
}
},
{
"start": "2018-01-24T00:00:00.000Z",
"end": "2018-01-24T19:59:12.488Z",
"requests/failed": {
"sum": 1392
}
}
]
}
}
},
{
"id": "count",
"status": 200,
"body": {
"value": {
"start": "2018-01-22T19:59:12.488Z",
"end": "2018-01-24T19:59:12.488Z",
"interval": "P1D",
"segments": [
{
"start": "2018-01-22T19:59:12.488Z",
"end": "2018-01-23T00:00:00.000Z",
"requests/count": {
"sum": 1225
}
},
{
"start": "2018-01-23T00:00:00.000Z",
"end": "2018-01-24T00:00:00.000Z",
"requests/count": {
"sum": 7382
}
},
{
"start": "2018-01-24T00:00:00.000Z",
"end": "2018-01-24T19:59:12.488Z",
"requests/count": {
"sum": 6674
}
}
]
}
}
}
]
Definitions
Name | Description |
---|---|
error |
Error details. |
error |
The code and message for an error. |
error |
Error details. |
Metric |
ID of the metric. This is either a standard AI metric, or an application-specific custom metric. |
Metrics |
The aggregation to use when computing the metric values. To retrieve more than one aggregation at a time, separate them with a comma. If no aggregation is specified, then the default aggregation for the metric is used. |
metrics |
A metric request |
metrics |
A metric result. |
metrics |
A metric result data. |
metrics |
A set of metric results. |
Metrics |
The name of the dimension to segment the metric values by. This dimension must be applicable to the metric you are retrieving. To segment by more than one dimension at a time, separate them with a comma (,). In this case, the metric data will be segmented in the order the dimensions are listed in the parameter. |
metrics |
A metric segment |
Parameters |
The parameters for a single metrics query |
errorDetail
Error details.
Name | Type | Description |
---|---|---|
additionalProperties |
object |
|
code |
string |
The error's code. |
message |
string |
A human readable error message. |
resources |
string[] |
Indicates resources which were responsible for the error. |
target |
string |
Indicates which property in the request is responsible for the error. |
value |
string |
Indicates which value in 'target' is responsible for the error. |
errorInfo
The code and message for an error.
Name | Type | Description |
---|---|---|
additionalProperties |
object |
|
code |
string |
A machine readable error code. |
details |
error details. |
|
innererror |
The code and message for an error. |
|
message |
string |
A human readable error message. |
errorResponse
Error details.
Name | Type | Description |
---|---|---|
error |
The code and message for an error. |
MetricId
ID of the metric. This is either a standard AI metric, or an application-specific custom metric.
Value | Description |
---|---|
availabilityResults/availabilityPercentage | |
availabilityResults/duration | |
billing/telemetryCount | |
client/networkDuration | |
client/processingDuration | |
client/receiveDuration | |
client/sendDuration | |
client/totalDuration | |
customEvents/count | |
dependencies/count | |
dependencies/duration | |
dependencies/failed | |
exceptions/browser | |
exceptions/count | |
exceptions/server | |
pageViews/count | |
pageViews/duration | |
performanceCounters/exceptionsPerSecond | |
performanceCounters/memoryAvailableBytes | |
performanceCounters/processCpuPercentage | |
performanceCounters/processIOBytesPerSecond | |
performanceCounters/processPrivateBytes | |
performanceCounters/processorCpuPercentage | |
performanceCounters/requestExecutionTime | |
performanceCounters/requestsInQueue | |
performanceCounters/requestsPerSecond | |
requests/count | |
requests/duration | |
requests/failed | |
sessions/count | |
users/authenticated | |
users/count |
MetricsAggregation
The aggregation to use when computing the metric values. To retrieve more than one aggregation at a time, separate them with a comma. If no aggregation is specified, then the default aggregation for the metric is used.
Value | Description |
---|---|
avg | |
count | |
max | |
min | |
sum | |
unique |
metricsPostBodySchema
A metric request
Name | Type | Description |
---|---|---|
id |
string |
An identifier for this query. Must be unique within the post body of the request. This identifier will be the 'id' property of the response object representing this query. |
parameters |
The parameters for a single metrics query |
metricsResult
A metric result.
Name | Type | Description |
---|---|---|
value |
A metric result data. |
metricsResultInfo
A metric result data.
Name | Type | Description |
---|---|---|
end |
string (date_time) |
Start time of the metric. |
interval |
string (duration) |
The interval used to segment the metric data. |
segments |
Segmented metric data (if segmented). |
|
start |
string (date_time) |
Start time of the metric. |
metricsResults
A set of metric results.
Name | Type | Description |
---|---|---|
body |
The results of this metric query. |
|
id |
string |
The specified ID for this metric. |
status |
integer (int32) |
The HTTP status code of this metric query. |
MetricsSegment
The name of the dimension to segment the metric values by. This dimension must be applicable to the metric you are retrieving. To segment by more than one dimension at a time, separate them with a comma (,). In this case, the metric data will be segmented in the order the dimensions are listed in the parameter.
Value | Description |
---|---|
applicationBuild | |
applicationVersion | |
authenticatedOrAnonymousTraffic | |
browser | |
browserVersion | |
city | |
cloudRoleName | |
cloudServiceName | |
continent | |
countryOrRegion | |
deploymentId | |
deploymentUnit | |
deviceType | |
environment | |
hostingLocation | |
instanceName |
metricsSegmentInfo
A metric segment
Name | Type | Description |
---|---|---|
end |
string (date_time) |
Start time of the metric segment (only when an interval was specified). |
segments |
Segmented metric data (if further segmented). |
|
start |
string (date_time) |
Start time of the metric segment (only when an interval was specified). |
Parameters
The parameters for a single metrics query
Name | Type | Description |
---|---|---|
aggregation |
The aggregation to use when computing the metric values. To retrieve more than one aggregation at a time, separate them with a comma. If no aggregation is specified, then the default aggregation for the metric is used. |
|
filter |
string |
An expression used to filter the results. This value should be a valid OData filter expression where the keys of each clause should be applicable dimensions for the metric you are retrieving. |
interval |
string (duration) |
The time interval to use when retrieving metric values. This is an ISO8601 duration. If interval is omitted, the metric value is aggregated across the entire timespan. If interval is supplied, the server may adjust the interval to a more appropriate size based on the timespan used for the query. In all cases, the actual interval used for the query is included in the response. |
metricId |
ID of the metric. This is either a standard AI metric, or an application-specific custom metric. |
|
orderby |
string |
The aggregation function and direction to sort the segments by. This value is only valid when segment is specified. |
segment |
The name of the dimension to segment the metric values by. This dimension must be applicable to the metric you are retrieving. To segment by more than one dimension at a time, separate them with a comma (,). In this case, the metric data will be segmented in the order the dimensions are listed in the parameter. |
|
timespan |
string |
The timespan over which to retrieve metric values. This is an ISO8601 time period value. If timespan is omitted, a default time range of |
top |
integer (int32) |
The number of segments to return. This value is only valid when segment is specified. |