So I created a Class library that configures microservices's Application Insights. These are the Application Insights configuration methods:
And this is how I use them in the Startup.cs class of each microservice:
It seems to be working fine, according to the debug logs:
I am even able to see the live metrics in azure correctly:
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:
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!
Microsoft.ApplicationInsights.Dev.GUID
it looks likeMicrosoft.ApplicationInsights.Dev.instrumenationkey=GUID
. It feels like key was set to string "instrumentationkey=GUID" instead of simply setting it to GUID instead. – Dmitry Matveev