Query - Execute
Execute an Analytics query
Executes an Analytics query for data. Here is an example for using POST with an Analytics query.
POST https://api.applicationinsights.io/v1/apps/{appId}/query
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 | Required | Type | Description |
|---|---|---|---|
| query | True |
string |
The query to execute. |
| applications |
string[] |
A list of Application IDs for cross-application queries. |
|
| timespan |
string |
Optional. The timespan over which to query data. This is an ISO8601 time period value. This timespan is applied in addition to any that are specified in the query expression. |
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
queryPost
Sample request
POST https://api.applicationinsights.io/v1/apps/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/query
{
"timespan": "PT12H",
"query": "requests | summarize count() by bin(timestamp, 1h)"
}
Sample response
x-ms-request-id: 58a37988-2c05-427a-891f-5e0e1266fcc5
x-ms-correlation-request-id: 58a37988-2c05-427a-891f-5e0e1266fcc5
{
"tables": [
{
"name": "PrimaryResult",
"columns": [
{
"name": "timestamp",
"type": "datetime"
},
{
"name": "count_",
"type": "long"
}
],
"rows": [
[
"2018-02-02T05:00:00Z",
"255"
],
[
"2018-02-01T17:00:00Z",
"148"
],
[
"2018-02-01T18:00:00Z",
"453"
],
[
"2018-02-01T19:00:00Z",
"404"
],
[
"2018-02-01T20:00:00Z",
"403"
],
[
"2018-02-01T21:00:00Z",
"405"
],
[
"2018-02-01T22:00:00Z",
"438"
],
[
"2018-02-01T23:00:00Z",
"403"
],
[
"2018-02-02T00:00:00Z",
"423"
],
[
"2018-02-02T01:00:00Z",
"403"
],
[
"2018-02-02T02:00:00Z",
"425"
],
[
"2018-02-02T03:00:00Z",
"437"
],
[
"2018-02-02T04:00:00Z",
"420"
]
]
}
]
}
Definitions
| Name | Description |
|---|---|
| column |
A table column. |
|
error |
Error details. |
|
error |
The code and message for an error. |
|
error |
Error details. |
|
query |
The Analytics query. Learn more about the Analytics query syntax |
|
query |
A query response. |
| table |
A query response table. |
column
A table column.
| Name | Type | Description |
|---|---|---|
| name |
string |
The name of this column. |
| type |
string |
The data type of this column. |
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. |
queryBody
The Analytics query. Learn more about the Analytics query syntax
| Name | Type | Description |
|---|---|---|
| applications |
string[] |
A list of Application IDs for cross-application queries. |
| query |
string |
The query to execute. |
| timespan |
string |
Optional. The timespan over which to query data. This is an ISO8601 time period value. This timespan is applied in addition to any that are specified in the query expression. |
queryResults
A query response.
| Name | Type | Description |
|---|---|---|
| tables |
table[] |
The list of tables, columns and rows. |
table
A query response table.
| Name | Type | Description |
|---|---|---|
| columns |
column[] |
The list of columns in this table. |
| name |
string |
The name of the table. |
| rows |
string[] |
The resulting rows from this query. |