【问题标题】:EventFlow does not show right telemetry types on ApplicationInsight portal. Instead they show as TRACEEventFlow 未在 ApplicationInsight 门户上显示正确的遥测类型。相反,它们显示为 TRACE
【发布时间】:2019-01-08 14:59:23
【问题描述】:

在我的示例项目中,我使用 EventFlow 来收集我的诊断数据并输出到 ApplicationInsight。日志记录也是通过 ApplicationInsight 完成的。诊断数据显示在 ApplicationInsight 门户上,但所有遥测类型都显示为 TRACE(即使诊断发送的遥测类型为 REQUEST)。但是,如果我直接使用 ApplicationInsight 登录(没有 EventFlow),它将在 ApplicationInsight 中正确显示正确的遥测类型。下面是我使用的 EventFlow 配置文件和示例代码。

顺便说一下,我的示例应用程序是 ASP.NET Core2 Web API。

eventFlowConfig.json

{

   "inputs": [
           { "type": "ApplicationInsights" }
  ],
  "outputs": [
    // Please update the instrumentationKey.
    {
      "type": "ApplicationInsights",
      "instrumentationKey": "xxxxxxxxxxx"
    }
  ],
  "schemaVersion": "2016-08-11"
}

示例代码

public void ConfigureServices(IServiceCollection services)
        {
            services.AddApplicationInsightsTelemetry();
            services.AddApplicationInsightsTelemetryProcessor<EventFlowTelemetryProcessor>();
            services.AddMvc();
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            var telemetryConfiguration = app.ApplicationServices.GetService<TelemetryConfiguration>();
            var eventFlowTelmetryProcessor = (EventFlowTelemetryProcessor)telemetryConfiguration
                                                .TelemetryProcessors
                                                .First(x => x.GetType() == typeof(EventFlowTelemetryProcessor));

            if (eventFlowTelmetryProcessor != null)
            {
                var diagnosticPipeline = app.ApplicationServices.GetService<DiagnosticPipeline>();
                eventFlowTelmetryProcessor.Pipeline = diagnosticPipeline;
            }

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseMvc();
        }

为了更清楚,我在这里附上了 ApplicationInsight 的屏幕截图。这里它有一些遥测类型为 REQUEST 的诊断数据,但即使是那些也显示为 TRACE。

【问题讨论】:

    标签: .net azure-service-fabric azure-application-insights event-flow


    【解决方案1】:

    这是因为 Event FlowAppInsights Ouput 使用 TrackTrace 来处理所有输入事件\遥测,并且这些事件被发送到 Trace ApplicationInsights 上的表。

    它还使用 AppInsights Event Type(Request) 来设置这些事件的 LogLevel,例如 Informational、Trace、Debug。

    由于这种不必要的处理,您在前往目的地的途中会丢失一些东西。为什么不直接记录到 appInsights,而不是添加这个额外的开销来解析到 eventFlow,然后发送到 AppInsights?

    【讨论】:

    • 感谢您的回复。这似乎是 EventFlow 与 AI 集成的一种限制。关于为什么不能直接使用 AI 的问题的答案是,在产品环境中,假设不使用 Azure 云环境,一切都在本地,但在 DEV 和 QA 中,它计划使用 Azure Cloud 上的遥测数据进行 DEV/QA团队内部参考。在产品中,遥测数据将被推送到 ElasticSearch 等第三方集成。
    • EventFlow 是开源的,如果您需要支持这类场景,我建议您获取代码副本并根据自己的需要进行定制。当前的实现必须是通用的以支持所有类型的场景,在您的情况下,您可能会面临与 ElasticSearch 输出类似的情况。请看这里:github.com/Azure/diagnostics-eventflow
    猜你喜欢
    • 2017-03-20
    • 2020-01-31
    • 2022-08-03
    • 2023-03-16
    • 2017-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-14
    相关资源
    最近更新 更多