Execute an Analytics query

Executes an Analytics query for data. Here is an example for using POST with an Analytics query.

HTTP request

POST /v1/apps/{app-id}/query

Security

Type Description
API key

Pass the API key via an X-Api-Key custom header or an api_key query parameter. [More info about authorization]

Basic Auth

Use the API key as either username or password with normal HTTP basic auth [More info about authorization]

Azure AAD Auth

Pass the AAD auth token in the 'Authorization' header. [More info about authorization]

URL parameters

Name Value Description
app-id string (uuid)

ID of the application. This is Application ID from the API Access settings blade in the Azure portal.

Query parameters

Name Value Description
timespan string (date-time-period)

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.

Body

The Analytics query. Learn more about the Analytics query syntax

{
  "description": "Query request body",
  "type": "object",
  "properties": {
    "query": {
      "description": "The Analytics query. Learn more about the [Analytics query syntax](https://azure.microsoft.com/documentation/articles/app-insights-analytics-reference/)",
      "type": "string"
    },
    "timespan": {
      "description": "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.",
      "type": "string",
      "format": "date-time-period"
    },
    "applications": {
      "description": "Application IDs to include in cross-application queries.",
      "type": "array",
      "collectionFormat": "csv",
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "query"
  ]
}
{
  "query": "traces | limit 10"
}
{
  "query": "requests | where timestamp > ago(1d) | summarize count() by operation_Name"
}

Responses

Status Code Description
200 Successful response
402 Payment required (the app is not in a required pricing tier)
404 Invalid app-id
429 Too many requests
503 Service unavailable