应用洞察和标签

Application Insights and Tags

我有 2 个应用程序 (asp.net) 集成了 Application Insights。 在门户中,我创建了 2 个标签:App1 = 1、App2 = 1(每个应用一个标签)。 但是下一步是什么? 如何将标签添加到 ApplicationInsights.config,以便每个应用程序发送其标签?

这不是标签的用途。他们在那里组织您的 Azure 资源,请参阅 https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-using-tags

Resource Manager enables you to logically organize resources by applying tags. The tags consist of key/value pairs that identify resources with properties that you define. To mark resources as belonging to the same category, apply the same tag to those resources.

如果您想区分这两个应用程序,您需要使用不同的检测密钥,这意味着两个不同的 Application Insights 环境。

来自https://docs.microsoft.com/en-us/azure/application-insights/app-insights-create-new-resource

The instrumentation key identifies the resource that you created. You'll need it to give to the SDK.

作为替代方案,您可以将自定义属性添加到您的 SDK 调用中,以区分您是否需要,如下所述:https://blogs.msdn.microsoft.com/visualstudioalm/2015/01/07/application-insights-support-for-multiple-environments-stamps-and-app-versions/ and Adding custom properties for each request in Application Insights metrics

所以这取决于网络应用程序的差异。如果它们不相关,我会建议使用不同的检测键。如果一个应用程序是 staging/test 应用程序而另一个是生产应用程序,那么您可以考虑使用自定义属性,以便您可以根据自定义 属性.

比较收集的数据