open-telemetry / opentelemetry-collector

OpenTelemetry Collector
https://opentelemetry.io
Apache License 2.0
4.25k stars 1.4k forks source link

Emit collector JSON logs with the message attribute #10612

Open clintonb opened 1 month ago

clintonb commented 1 month ago

Is your feature request related to a problem? Please describe.

Datadog and Google use the message attribute as the main body of the log message. This value is used for basic search and log tailing.

Usage of the msg attribute by the collector makes log spelunking a bit tedious.

Describe the solution you'd like

There are a few options:

  1. Only use the message attribute.
  2. Use both the message and msg attributes.
  3. Allow the attribute to be defined via configuration. For example:
    service:
    telemetry:
    logs:
      encoding: json
      body_attribute: message
clintonb commented 1 month ago

Related: https://github.com/open-telemetry/opentelemetry-collector/issues/4740#issuecomment-1440747441

atoulme commented 1 month ago

We could dxpose zapcore.EncoderConfig. You can override messageKey then.

TylerHelmuth commented 1 month ago

Ultimately the collectors telemetry will follow OpenTelemetry Semantic conversions. Those haven't yet been decided for the collector, but the conversation has started.