Connect Application Insights with PowerBI using Application Insights Query

Connect Application Insights with PowerBI using Application Insights Query

Application Insights is an extensible Application Performance Management (APM) service for web developers building and managing apps on multiple platforms. In layman's terms application insights, commonly called as app insights is used to get detailed, accurate and deep insights (understanding) of your application. App insights can help in various scenarios like from understanding the root cause of an issue to finding the number of users visiting your application. The use cases for app insights are endless. A glimpse of some of the things app insights can monitor are:

  • Request rates, response times, and failure rates
  • Dependency rates, response times, and failure rates
  • Exceptions
  • Page views and load performance
  • User and session counts
  • Performance counters, etc.

Now the majority of these insights are aimed at the development team, but these data can also add huge value to the business owners as that will help them understand the application better (e.g. No of users using the application). But this poses a challenge, you can't show a table full of data to your business owners; they won't understand anything, they need a summarized version of the data and even better a visual representation of that data. That's were PowerBi comes into the picture. Power BI is a business analytics service provided by Microsoft, which provides interactive visualization with self-service business intelligence capabilities.

This blog aims at visualizing the insights received from App insights via PowerBi.

To get started, you need an app insights which receives telemetry of your application and the desktop version of PowerBi.

  1. First, let's go to the app service and navigate to the application insights connected with it. navigate-to-app-insights-1.png
  2. And let's steer to the 'Analytics' tab of the app insights so that we can write a query to retrieve data. navigate-to-analytics-1.png
  3. Test and refine the query until you're happy with the results. Make sure that the query runs correctly in Analytics. analytics-query-1.png
  4. Once you have figured out the query, now its time to export the query to a Power Bi (M query) and use it in PowerBi. Click on the export button on the menu bar where the 'Save' button exists and click on the Export to Power Bi (M Query). Save the text file. export-to-powerbi-m-query-1.png
  5. Now open your Power Bi Desktop, that should get you started with a new empty report. Select Get Data > Blank Query. Then, in the query editor, under View, select Advanced Editor. Paste the exported M Language script into the Advanced Editor. power-bi-import-analytics-query-1.png
  6. Now you should be popped up with a window which asks you for authenticating the query. In this blog, we are gonna authenticate this with an app insights API key. authentication-1.png
  7. To obtain the app insights API key, navigate back to your app insights inside the Azure portal
    1. Click on the API Access.
    2. Click Create API Key.
    3. Enter a short description, check the Read telemetry option, and click the Generate key button. (Make sure you check the Read telemetry option, without this Power Bi won't be able to read the data and the key would be useless.) portal-app-insights-appid-apikey-1.png
    4. Copy this API key and save it because this key will never be shown to you again. If you lose this key, you have to create a new one.
  8. Now back in the PowerBi window, you need to add this key. And here comes the tricky part.
    1. Click on the Basic mode of authentication.
    2. Paste in the copied key in both User name and Password field. (Yes same key in both user name and password.) basic-authentication-1.png
  9. Click on 'Close & Apply ' and its time to choose a visualization for your query data. query-authenticated-1.png
  10. Now it's up to you the way you wanna design your power bi report. Once done, publish your report to your Power BI cloud workspace. power-bi-report-1.png power-bi-report-publish-1.png

That's it. You have connected Application Insights with PowerBI using Application Insights Query and API key.

Did you find this article valuable?

Support Kumar Ashwin Hubert by becoming a sponsor. Any amount is appreciated!