-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Conversation
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]>
lib/fluent/plugin/in_http.rb
Outdated
single_time = time | ||
end | ||
|
||
unless @parser and @parser.keep_time_key |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
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]>
5f7ea1c
to
39f3a0d
Compare
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]>
I have added a test case for this usage pattern in d0809c6. |
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 processingthose bulk-insertion requests.
This means that "time" key in each record gets discarded unconditionally in batch mode.
For example, the following request:
will produces a log record:
... 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 parserplugin instance.
Signed-off-by: Fujimoto Seiji [email protected]