For querying App Insights traces, should we query the Application Insights REST API or the Log Analytics Rest API?

NSou 21 Reputation points

Both the Application Insights REST API and the Log Analytics REST API seem to support similar queries. I thought that App Insights logged to a Log Analytics Workspace, but now I feel confused... what is the relationship between these and which should we be querying to retrieve trace data logged by our application? Thanks.

Update: I now see an Azure Data Explorer SDK also. Which one of these 3 should I use??

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
1,951 questions
{count} votes

1 answer

Sort by: Most helpful
  1. SwathiDhanwada-MSFT 9,651 Reputation points

    For the benefit of the community, re-posting the answer posted by community member.

    The difference between #1 and #2 is mostly historical and converging.

    • Application Insights existed as a product before log analytics, and were based on different underlying database technologies
    • Both Application Insights and Log Analytics converged to use the same underlying database, based on ADX (Azure Data Explorer), and the same exact REST API service to query either. So while your #1 and #2 links are different, they point to effectively the same service backend by the same team, but the pathing/semantics are subtly different where the service looks depending on the inbound request.
    • both AI and LA introduce the concept of multi-tenancy and a specific set of tables/schema on top of their azure resources. They effectively hide the entire database from you, and make it look like one giant database.
    • there is now the possibility (suggested) to even have your Application Insights data placed in a Log Analytics Workspace, this lets you put the data for multiple AI applications/components into the SAME log analytics workspace, to simplify query across different apps, etc
    • Think of ADX as any other kind of database offering. If you create an ADX cluster instance, you have to create database, manage schema, manage users, etc. AI and LA do all that for you. So in your question above, the third link to ADX SDK would be used to talk to an ADX cluster/database directly. I don't believe you can use it to directly talk to any AI/LA resources, but there are ways to enable an ADX cluster to query AI/LA data: and ways to have a LA/AI query also join with an ADX cluster using the adx keyword in your query: