Logging SQL Queries with Application Insights
The more I use Log Analytics the bigger the fan of Application Insights I’m becoming. The query language is fantastic, the Application Insights service and tooling around it amazing. Yesterday I added Application Insights logging in our QA environment as well, to track SQL queries in particular so we can create some clever queries that can help us figure out if we are having SQL related performance problems.
We use the Application Insights NuGet package for all our services (in our logging library), but the SQL queries weren’t being logged. A few years ago, when we hosted the services on Azure using Cloud Services we got everything out of the box, but this time I had to configure the environment manually. Here is how:
Install Application Insights using the Web Installer on the server
Associate Application Insights with your account
Restart IIS
Add the service account running your web services to the Performance Monitor Users groups
Give it a minute or two and the queries should start showing up in Log Analytics.
Comments
Last modified on 2018-03-15