How can I query azure application insights as azure log analytics?

Hi,

I have setup the azure monitor plugin, with azure application insights. With this set up I can create graphs based on the metrics in application insights. In azure I can go from application insights to log analytics and do some queries, but I can’t seem to find out how I can do that in Grafana (There is no workspace for the app insights). So I can’t access my logs in application insights. Can someone help me with this?

Thanks,
André

So on https://grafana.com/grafana/plugins/grafana-azure-monitor-datasource it says:

Application Insights metrics

Anyone who used this or knows someone who does?

Hi @avollering have you solved this? According to the following commit, it seems to me that the support for raw log analytics queries might have been added in Grafana 6.6

Thanks

Hi jirikoutnydatasentic, No I’ve actually dropped this solution and went for kubernetes -> prometheus -> grafana. Thanks for the repsonse!

In case anyone is looking for how to do this

  • create a connection to Azure Log Analytics API using the same details as you did for Azure Monitor API.

  • change your query type to Log Analytics

  • write your query qualifying your table names as follows : app('AppInsightsInstanceName').tableName

      app('app01').exceptions
      | summarize count() by problemId
    

Note: it appears that Azure Log Analytics is broken in v6.6 so use a previous version (I’m on v6.5.1)

3 Likes

Adding to what @myeviltwinxi has replied if you intend to plot a time series graph make sure you add the following in your query:

| project Timegenerated=timestamp, problemId

As a rule of thumb, log analytics collects timestamp under the column “TimeGenerated” and application insights collects it simply as timestamp. If you want to use the inbuilt grafana filter like $__interval, you would need to rename timestamp to timegenerated otherwise you would get an error: “Data outside time range”

An example query (to plot the average duration of a request) would like as follow:

app("/subscriptions/XXX-XXXX-Subsciprtion-ID/resourceGroups/XXResourceGroupName/providers/microsoft.insights/components/XXX-App-Insight-Name").requests
| where url contains "something" 
| project Timegenerated=timestamp, duration
| summarize something_avg=avg(duration) by bin(Timegenerated, $__interval) 
| order by Timegenerated asc

We are running 6.6.2 and have no issues with this query