0

Our application is using azure application insights. What I read is that, using application insights end to end tracking, we can even get the query which gets executed at database and how much time that query took.

But as shown in the screenshot, azure app insights shows me that there are 3 calls made to database but not the actual query that was executed against the database in those calls.

What I need to know is that what i need to do inorder to get the query that was executed against the database?

enter image description here

1
  • It's a .net core project or .net framework project? Commented Jun 26, 2020 at 6:07

2 Answers 2

7

This is one of breaking changes as part of SDK 2.14.

You just need to simply modify ConfigureServices() with the line below for ASP.NET Core:

services.ConfigureTelemetryModule<DependencyTrackingTelemetryModule>((module, o) => { module.EnableSqlCommandTextInstrumentation = true; });

and for ASP.NET modify ApplicationInsights.config file:

<Add Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector">, 
<EnableSqlCommandTextInstrumentation>true</EnableSqlCommandTextInstrumentation>
</Add>
Sign up to request clarification or add additional context in comments.

1 Comment

1

Yes, the application insights can track sql query. But note that there are some changes in the latest version of application insights nuget package, which makes it does not automatically track sql query.

You can do it via the workaround below.

Assume you're using the .net core web project. Then you need to downgrade the Microsoft.ApplicationInsights.AspNetCore to version 2.12.0.

Here is my test result with version 2.12.0 of that package:

enter image description here

And also, you can use other workarounds, see here for more details.

2 Comments

How would I then query the AppInsights log with KQL to find that request which included that specific SQL Command?
Looking for answer on how to query this too...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.