open-telemetry / opentelemetry-collector-contrib

Contrib repository for the OpenTelemetry Collector
https://opentelemetry.io
Apache License 2.0
2.9k stars 2.27k forks source link

Ability to define multiple filelog receivers OR apply different tags based on log file #34256

Open jamesqo opened 1 month ago

jamesqo commented 1 month ago

Component(s)

cmd/otelcontribcol

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

I am trying to set up the OpenTelemetry collector to send logs to Datadog using the Datadog exporter. Here is what the relevant portion of my configuration file looks like:

receivers:
  otlp:
    protocols:
      grpc:
  filelog:
    include:
        - /data/portal-cron/logs/validation_utils_py3.json
        - /data/portal-cron/logs/cvr-fetcher.log
    start_at: beginning
    attributes:
      ddtags: host:pipelines3.cbioportal.aws.mskcc.org

This will cause all events sent to Datadog to be tagged with host:pipelines3.cbioportal.aws.mskcc.org. But let's say I only want to apply this tag to events read from cvr-fetcher.log. I don't see an option to do this-- either by defining multiple filelog receivers, or perhaps there is some setting I'm missing? I have looked at the receiver schema here, but I could not find anything.

Describe the solution you'd like

Ability to set up multiple filelog receivers (this fork seems to have that ability, Ctrl+F search "multiple filelog receivers"), or apply ddtags only to specific log files

Describe alternatives you've considered

No response

Additional context

No response

github-actions[bot] commented 1 month ago

Pinging code owners for receiver/filelog: @djaglowski. See Adding Labels via Comments if you do not have permissions to add labels yourself.

djaglowski commented 1 month ago

You can define multiples of any component by adding /name to the component type:

receivers:
  otlp:
    protocols:
      grpc:
  filelog:
    include:
        - /data/portal-cron/logs/validation_utils_py3.json
    start_at: beginning
    attributes:
      ddtags: host:pipelines3.cbioportal.aws.mskcc.org
  filelog/2:
    include:
        - /data/portal-cron/logs/cvr-fetcher.log
    start_at: beginning

Then just refer to each on in your pipelines:

service:
  pipelines:
    logs:
      receivers: [ otlp, filelog, filelog/2 ]
      processors: ...
      exporters: ...