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

in_http: Honor keep_time_key parameter in batch mode. #2020

Merged
merged 3 commits into from
Jun 19, 2018

Conversation

fujimotos
Copy link
Member

This patch fixes the issue reported by Eugen Cristea at fluent/fluentd-docs#507.

Problem

in_http plugin supports "batch" mode for sending multiple events in a single HTTP request.
The problem is that in_http does not honor the keep_time_key option when processing
those bulk-insertion requests.

This means that "time" key in each record gets discarded unconditionally in batch mode.
For example, the following request:

$ curl -d '[{"time":1514736000,"key":"foo"}]' http://localhost/

will produces a log record:

2018-01-01 01:00:00.000000000 +0900 : {"key":"foo"}

... even if the keep_time_key option is enabled.

Solution

This patch fixes this issue by teaching in_http to honor the option value of its parser
plugin instance.

Signed-off-by: Fujimoto Seiji [email protected]

The in_http plugin supports "batch" mode for sending multiple events in
a single HTTP request. The problem is that in_http does not honor the
`keep_time_key` option when processing those bulk-insertion requests.

This means that "time" key in each record gets discarded unconditionally
in batch mode. For example, the following request:

    $ curl -d '[{"time":1514736000,"key":"foo"}]' http://localhost/

will produces a log record:

    2018-01-01 01:00:00.000000000 +0900 : {"key":"foo"}

even if the `keep_time_key` option is enabled.

This patch fixes this issue by teaching in_http to honor the option
value of its parser plugin instance.

Signed-off-by: Fujimoto Seiji <[email protected]>
single_time = time
end

unless @parser and @parser.keep_time_key
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition can be moved to under above if single_record._has_key?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed this point by 39f3a0d

fujimotos pushed a commit to fujimotos/fluentd that referenced this pull request Jun 18, 2018
Pointed out by repeatedly in the patch review. See the conversation
in the following ticket for details:

    fluent#2020
Pointed out by repeatedly in the patch review. See the conversation
in the following ticket for details:

    fluent#2020

Signed-off-by: Fujimoto Seiji <[email protected]>
@repeatedly
Copy link
Member

Could you add test?

This patch adds a test case (test_multi_json_with_keep_time_key) to
test_in_http.rb.

I've confirmed it passes without problems in my testing machine:

    test_multi_json_with_keep_time_key:            .: (0.606005)

Signed-off-by: Fujimoto Seiji <[email protected]>
@fujimotos
Copy link
Member Author

Could you add test?

I have added a test case for this usage pattern in d0809c6.

@repeatedly repeatedly merged commit 84c2194 into fluent:master Jun 19, 2018
@fujimotos fujimotos deleted the sf/honor-keep-time-key branch June 22, 2018 06:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants