3
votes

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://docs.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!

2
How do you check it in Log Analytics(it's better if you can provide a screenshot)? Can you see the data in azure portal -> application insights -> Logs?Ivan Yang
On the screenshot of VS output, instrumentation key looks a bit weird: instead of simple GUID in Microsoft.ApplicationInsights.Dev.GUID it looks like Microsoft.ApplicationInsights.Dev.instrumenationkey=GUID. It feels like key was set to string "instrumentationkey=GUID" instead of simply setting it to GUID instead.Dmitry Matveev
@DmitryMatveev you are right! In the keyvault the secret is the entire connection string! Looks like I copy-pasted the connection and not the instrumentation key only! Thank you so much!vitonimal
@IvanYang no it does not show anything (0 results). The problem is that I somewhat copy pasted the connection string in the keyvault instead of the instrumentation keyvitonimal
@DmitryMatveev I fixed the secret in keyvault and it works perfectly!vitonimal

2 Answers

1
votes

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.

1
votes

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.