Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opentelemetry-collector processors/routing use custom http header can not route to right exporters #30393

Closed
burning954320420 opened this issue Jan 10, 2024 · 5 comments
Labels
bug Something isn't working needs triage New item requiring triage processor/routing Routing processor

Comments

@burning954320420
Copy link

Component(s)

processor/routing

Describe the issue you're reporting

I want fluent-bit collect logs and push to opentelemetry-collector, then the opentelemetry-collector can get fluent-bit output custom http header, finally the opentelemetry-conllector based on fluent-bit output http header to different exporter. So I try to use processors/routing.

But the logs always output to default exporter, never output to desired exporter.

My fluentbit config is

[INPUT]
    Name        tail
    Path        /tmp/test.log

[OUTPUT]
    Name                 opentelemetry
    Match                *
    Host                 localhost
    Port                 4318
    Logs_uri             /v1/logs
    Header               X-Custom-Logs-Header custom

My opentelemetry-collector config is

receivers:
  otlp:
    protocols:
      http:

exporters:
  file/default:
    path: /data/default.log
  file/custom:
    path: /data/custom.log

processors:
  routing:
    attribute_source: context
    from_attribute: X-Custom-Logs-Header
    default_exporters: [file/default]
    table:
    - value: custom
      exporters:
      - file/custom

service:
  pipelines:
    logs:
      receivers: [otlp]
      processors: [routing]
      exporters: [file/default, file/custom]

I expect fluentbit input the /tmp/test.log and opentelemetry-conllector written to /data/custom.log, but it written to /data/default.log.
I used tcpdump command to get opentelemetry-conllector packet, and X-Custom-Logs-Header header really in the opentelemetry-conllector http port when fluentbit post to opentelemetry-conllector.

@burning954320420 burning954320420 added the needs triage New item requiring triage label Jan 10, 2024
@github-actions github-actions bot added the processor/routing Routing processor label Jan 10, 2024
Copy link
Contributor

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@crobert-1 crobert-1 added the bug Something isn't working label Jan 10, 2024
@crobert-1
Copy link
Member

Hello @burning954320420, thanks for filing this issue! Usually when all of your data is going to the default exporter it means that your incoming data is formatted differently than expected when being compared to the table.value configuration option.

Can you share a few example log messages? Preferably using the debug exporter.

Here's a sample config that would display what I'm requesting:

receivers:
  otlp:
    protocols:
      http:

exporters:
  debug:
    verbosity: detailed

service:
  pipelines:
    logs:
      receivers: [otlp]
      processors: []
      exporters: [debug]

@burning954320420
Copy link
Author

@crobert-1 Thank you for your help. I config exporters.debug, and the opentelemetry-collector log like:

2024-01-11T01:59:54.106Z        info    LogsExporter    {"kind": "exporter", "data_type": "logs", "name": "debug", "resource logs": 1, "log records": 1}
2024-01-11T01:59:54.107Z        info    ResourceLog #0
Resource SchemaURL: 
ScopeLogs #0
ScopeLogs SchemaURL: 
InstrumentationScope  
LogRecord #0
ObservedTimestamp: 1970-01-01 00:00:00 +0000 UTC
Timestamp: 2024-01-11 01:59:53.989822498 +0000 UTC
SeverityText: 
SeverityNumber: Unspecified(0)
Body: Map({"log":"a"})
Trace ID: 
Span ID: 
Flags: 0
        {"kind": "exporter", "data_type": "logs", "name": "debug"}

But I feel that it may not be possible to see HTTP header information in the exporters.

And I capture the packet in opentelemetry-collector http 4318 port, the packet like that:
image
So I think opentelemetry-collector get the custom header, but for some reason processor/routing not get the header or routing processing failed.

@crobert-1
Copy link
Member

It looks like you need to add include_metadata: true as an option to your receiver, this way the context will be preserved in your logs. More information on this configuration option can be found here.

Here's what your receiver configuration should look like:

receivers:
  otlp:
    protocols:
      http:
        include_metadata: true

@burning954320420
Copy link
Author

@crobert-1 Thank you for your help. I have resolved the issue by adding the include_metadata configuration. Thank you once again for your assistance.

@burning954320420 burning954320420 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage New item requiring triage processor/routing Routing processor
Projects
None yet
Development

No branches or pull requests

2 participants