Using the API

This section will walk through the basics of using the Application Insights APIs. This assumes that you have an Application ID and an API key with read permissions for this application.

To try out these queries for yourself, you can either use this site's API Explorer or execute these from the command line with cURL.

About Application Insights data

Application Insights stores the telemetry collected about your application in two forms:

  1. Aggregated data: your app's telemetry data is aggregated during ingestion into the Application Insights service to form metrics with an associated set of dimensions. Because this data is pre-aggregated, it can be retained for longer periods and is very fast to query. An example of a metric would be request duration with dimensions such as the operating system and browser from which the request originated. In the Application Insights portal, this information is available on chart tiles and on Metrics Explorer blades. To query this data programatically, use the /metrics API.

  2. Event data: your app's telemetry data is also retained by Application Insights and in the portal this is available down to individual events either by using the Search blade or by opening the Analytics portal. This data can be queried via two different APIs: events and query, both of which support retrieving either individual events or aggregating these with an range of options -- such as filters -- applied. Both of these are REST APIs, and events supports OData so that it is easy to integration into applications such as Power BI and Excel. Using query enables programmatic access to their app's data using the same queries they can run in the Application Insights Analytics portal

Summary of data Application Insights stored data and the relevant APIs:

Stored data API Notes
Aggregated data /metrics /metrics retrieves aggregated data
Event data /events
/events supports OData
/query runs Analytics queries

Learn more about these APIs

The links below provide more data to learn these APIs:

  1. Metrics: reference and scenario walkthrough
  2. Events: reference and scenario walkthrough
  3. Query: reference and scenario walkthrough