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:
但是,数据不会在 Log Analytics 中“保存”,因此我无法对数据运行任何查询(它始终返回 0 个结果)。
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.
我确实阅读了这个文档:https://learn.microsoft.com/en-us/azure/azure-monitor/app/asp-net-core https://learn.microsoft.com/en-us/azure/azure-monitor/app/asp-net-core但我似乎没有错过任何步骤(我称之为 AddApplicationInsights 和 AddApplicationInsightsKubernetesEnricher)。
我想知道是否有人可以看到这个问题,我真的不知道如何通过实时指标而不是 Log Analytics 查看数据。
注意:在使用完全相同的代码(当您使用 VS 时生成的默认代码)实现库之前,我确实尝试添加应用程序见解right click on project > Setup Application Insights
它工作得很好。
非常感谢!