Datadog代理OpenTelemetry日志摄取

huangapple go评论70阅读模式
英文:

Datadog agent opentelemetry log ingest

问题

I am sending metrics and traces to a DD agent through opentelemetry otel exporter to the GRPC endpoint. This setup however, is not working for logs. My configuration:

builder.Logging.AddOpenTelemetry(ops =>
{
    ops.IncludeScopes = true;
    ops.ParseStateValues = true;
    ops.IncludeFormattedMessage = true;
    ops.AddOtlpExporter(cfg =>
    {
        cfg.Endpoint = new Uri("localhost:4317");
    });
});

Then, I am using the ILogger<T> instances to log information. Why is that not sent to DD?

英文:

I am sending metrics and traces to a DD agent through opentelemetry otel exporter to the GRPC endpoint. This setup however, is not working for logs. My configuration:

builder.Logging.AddOpenTelemetry(ops =&gt;
{
    ops.IncludeScopes = true;
    ops.ParseStateValues = true;
    ops.IncludeFormattedMessage = true;
    ops.AddOtlpExporter(cfg =&gt;
    {
        cfg.Endpoint = new Uri(&quot;localhost:4317&quot;);
    });
});

Then, I am using the ILogger&lt;T&gt; instances to log information. Why is that not sent to DD?

答案1

得分: 2

DD Agent目前不支持OTLP日志。 DD代理的OTLP接收器仅适用于指标和跟踪。我们正在努力扩展对日志的支持。

英文:

DD Agent currently doesn't support OTLP logs. The OTLP intake of the DD agent only works for metrics & traces. We are working on expanding the support to Logs.

答案2

得分: 1

我对DataDog不熟悉,所以无法确定这是否是一个DataDog特定的问题。但是,从逆向工作的角度来看,以下是我解决此问题的方法:

验证遥测数据是否到达您的收集器

看起来您正在通过托管在localhost:4317上的OpenTelemetry Collector将数据从应用程序发送出去。您可以使用Logging Exporter配置收集器,以验证从您的应用程序发出的遥测数据是否到达您的本地收集器。

使用这个收集器的最小配置,从您的应用程序成功导出并到达收集器的日志将被写入stdout。如果您看到日志,那么这确认了您已经正确配置了.NET SDK,您的问题可能在于配置收集器以导出到DataDog。

receivers:
  otlp:
    protocols:
      grpc:

exporters:
  logging:
    verbosity: detailed

service:
  pipelines:
    logs:
      receivers: [otlp]
      exporters: [logging]

验证.NET SDK 是否正确配置

如果在前面的步骤中没有看到任何写入stdout的日志,则.NET SDK 可能没有正确配置。

.NET SDK具有自诊断功能可以启用,以便排除任何配置问题。尝试启用它,并查看日志是否有任何错误。

根据您提供的代码,一个潜在的问题是您在配置的端点中没有指定方案。localhost:4317 应该是 http://localhost:4317。否则,您的应用程序将无法启动,并且您将收到类似 "Endpoint URI scheme is not supported. Currently only "http" and "https" are supported." 的异常。

英文:

I am not familiar with DataDog, so I cannot be sure if this is a DataDog specific issue. However, working backwards, here's how I would approach troubleshooting this issue:

Validate telemetry reaches your collector

It appears you are sending data from your application through an OpenTelemetry Collector hosted at localhost:4317. You can configure the collector with the Logging Exporter to validate that telemetry emitted from your app is reaching your local collector.

Using this minimal configuration for your collector, logs that are successfully exported from your application and reach the collector will be written to stdout. If you see logs, then this confirms that you have configured the .NET SDK correctly, and your issue is likely with configuring the collector to export to DataDog.

receivers:
  otlp:
    protocols:
      grpc:

exporters:
  logging:
    verbosity: detailed

service:
  pipelines:
    logs:
      receivers: [otlp]
      exporters: [logging]

Validate the .NET SDK is configured correctly

If you did not see any logs written to stdout in the previous step, then the .NET SDK may not be configured correctly.

The .NET SDK has a self-diagnostics feature you can enable in order to troubleshoot any configuration issues. Try enabling it, and review the logs for any errors.

Looking at the code you've provided, one potential issue is that you have not specified a scheme in the endpoint you've configured. localhost:4317 should be http://localhost:4317. Otherwise, your application will fail to start and you'll receive an exception like "Endpoint URI scheme is not supported. Currently only "http" and "https" are supported."

huangapple
  • 本文由 发表于 2023年6月8日 18:30:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/76430944.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定