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

Secondary formatting #167

Open
dtmistry opened this issue Dec 17, 2018 · 1 comment
Open

Secondary formatting #167

dtmistry opened this issue Dec 17, 2018 · 1 comment

Comments

@dtmistry
Copy link

I'm trying to use a file/s3 output as a <secondary> if sending events to Kinesis is failing. But the way the plugin formats incoming events makes its harder to read from a secondary file or S3

Original message (json) -

{"test":"this is a test message", "message_id":"1234"}
{"test":"this is a test message", "message_id":"123456"}
{"test":"this is a test message", "message_id":"456789"}

Message in secondary output (file or S3) -

36cbd167849700a041b3bd691b014937íƒì{"test":"this is a test message", "message_id":"1234"}Ÿ c762173994c445b6927e569fa0821e6fíƒî{"test":"this is a test message", "message_id":"123456"}Ÿ 3cb59c12b2209ec3728795c6c58af6abíƒì{"test":"this is a test message", "message_id":"456789"}Ÿ 

This is because of the format method implementation which adds a Hex of the event as the partition key

https://github.com/awslabs/aws-fluent-plugin-kinesis/blob/master/lib/fluent/plugin/out_kinesis_streams.rb#L39

Would it make sense to just format the message with the configured formatter in the format method and calculate the hex in the write method? That way secondary outputs can keep the desired formatting.

Environment -

td-agent3 running in a Ubuntu 14.04 container
fluent-plugin-kinesis-2.1.1

config -

<match carting.*>
    # plugin type
    @log_level debug
    @type kinesis_streams

    # your kinesis stream name
    stream_name test_stream
    # aws region
    region us-east-1
    <buffer>
      retry_max_times 3
      flush_interval 10s
      flush_thread_interval 0.1
      flush_thread_burst_interval 0.01
      flush_thread_count 4
    </buffer>
    <format>
        @type json
    </format>
    <secondary>
        @type file
        path /fluentd/log/failed_events
        <format>
            @type json
        </format>
    </secondary>
</match>
@yang-wei
Copy link

yang-wei commented Feb 2, 2021

facing the same issue too with https://docs.fluentd.org/output#secondary-output

where my logs look like

�={"key":"value"}�$3544c5eb-6536-11eb-8db1-0ea64c53eca3

3544c5eb-6536-11eb-8db1-0ea64c53eca3 is partition key

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants