vitonimal
vitonimal

Reputation: 473

Application Insights showing in Live metrics, but not in log analytics

So I created a Class library that configures microservices's Application Insights. These are the Application Insights configuration methods: enter image description here

And this is how I use them in the Startup.cs class of each microservice: enter image description here

It seems to be working fine, according to the debug logs: enter image description here

I am even able to see the live metrics in azure correctly: enter image description here

However, the data does not get 'saved' in Log Analytics, so I cannot run any query on the data (it always returns 0 results).

I thought that this could probably be because of the following code in the Program.cs of each microservice: enter image description here I thought that maybe the application insights logger was not configured correctly (not explicitely setting the instrumentation key). However, I tried to set the instrumentation key of the TelemetryConfiguration to the hardcoded Instrumentation Key, but it did not do anything.

I did read through this documentation: https://learn.microsoft.com/en-us/azure/azure-monitor/app/asp-net-core But I do not seem like I am missing any step (I call AddApplicationInsights and AddApplicationInsightsKubernetesEnricher).

I was wondering if anyone could see the issue, I really do not know how the data could be seen by live metrics and not Log Analytics.

Note: I did try to add application insights before implementing the library with the exact same code (the default code that VS generates when you right click on project > Setup Application Insights and it worked perfectly.

Many many thanks!

Upvotes: 6

Views: 3126

Answers (2)

Crhistian
Crhistian

Reputation: 1292

I had this same issue and it was because my instrumentation key had an extra white space that I didn't see, so be sure to double check it. I'm still not 100% sure how data was coming in at all via livestream. I guess that just works without an instrumentation key.

Upvotes: 1

Ivan Glasenberg
Ivan Glasenberg

Reputation: 30025

Here is the summarization for others who may also have the same issue:

As per Dmitry mentioned, the correct format in vs output should be Microsoft.ApplicationInsights.Dev.GUID, not Microsoft.ApplicationInsights.Dev.instrumenationkey=GUID. Here is the screenshot for the correct one:

enter image description here

And as per op's comment, in keyvault, just copy pasted the connection string in the keyvault instead of the instrumentation key which causes this error. The solution is change it to instrumentation key directly in keyvault.

Upvotes: 2

Related Questions