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.
- First, let's go to the app service and navigate to the application insights connected with it.
- And let's steer to the 'Analytics' tab of the app insights so that we can write a query to retrieve data.
- Test and refine the query until you're happy with the results. Make sure that the query runs correctly in Analytics.
- 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.
- 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.
- 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.
- To obtain the app insights API key, navigate back to your app insights inside the Azure portal
- Click on the API Access.
- Click Create API Key.
- 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.)
- 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.
- Now back in the PowerBi window, you need to add this key. And here comes the tricky part.
- Click on the Basic mode of authentication.
- Paste in the copied key in both User name and Password field. (Yes same key in both user name and password.)
- Click on 'Close & Apply ' and its time to choose a visualization for your query data.
- 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.
That's it. You have connected Application Insights with PowerBI using Application Insights Query and API key.