Skip to content

Use out_http to send logs to in_http #2909

@Gellardo

Description

@Gellardo

Check CONTRIBUTING guideline first and here is the list to help us investigate the problem.

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

I have 2 managed k8s clusters with individual fluentd services and want to forward some logs from cluster_1 to cluster_2. I can't use the forward protocol because the ingress does not allow raw TCP forwarding.

Instead I tried to use out_http in cluster_1 and in_http in cluster_2, since HTTP based ingress configurations are easy to do. But I couldn't find a working configuration, all failed with one of:

  • 400 Bad Request\nReceived event is not json
  • 400 Bad Request\n'json' or 'msgpack' parameter is required
  • Server: incoming event is invalid: path=/some.tag params={"json":"{\"hello\":\"world\",\"num\":18}\n{\"hello\":\"world\",\"num\":19}\n",...}

Describe the solution you'd like

There should be an easy configuration to allow using http to forward events between 2 fluentd instances.
I see 2 possible solutions:

  • add an option to out_http to optionally wrap (json) events in an (json) array
  • add an option to in_http/parse_json to be able to handle the json lines format used by out_http

Describe alternatives you've considered

Declare the out_http -> in_http case to be out of scope. In that case there should be some mention of it in the docs, to save the next person time. Two plugins which communicate over HTTP but can't talk to one another is very counter-intuitive in my opinion.

Additional context
Configuration for reproducing the problem.

# sending side
<source>
  @type dummy
  dummy {"hello":"world"}
  auto_increment_key num
  tag kube.test.tag
</source>

<match **>
  @type http
  endpoint http://localhost:9881/$tag
  open_timeout 2
  #content_type application/json #results in 'invalid event' if uncommented
  <format>
    @type json
  </format>
  <buffer>
    flush_interval 2s
  </buffer>
</match>
# receiving side
<source>
  @type http
  port 9881
  bind 0.0.0.0
  <parse> # comment out for 'json parameter required'
    @type json
  </parse>
</source>
<match **>
  @type stdout
</match>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions