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

format in_tail path with the specified timezone #2719

Merged
merged 1 commit into from
Dec 19, 2019

Conversation

tatsu-yam
Copy link
Contributor

Which issue(s) this PR fixes:
None

What this PR does / why we need it:
If the file path which in_tail plugin reads includes strftime format, it is determined by system timezone.
I want to determine this path in the specified timezone for each tail plugin object.
For example, a fluentd process reads a UTC file path ( /path/to/data/test_utc/20191210_04.json ) and a JST file path ( /path/to/data/test_jst/20191210_13.json ) in one conf.

$ TZ='Asia/Tokyo' ./bin/fluentd -c test.conf
2019-12-10 13:48:19 +0900 [info]: parsing config file is succeeded path="test.conf"
2019-12-10 13:48:19 +0900 [info]: using configuration file: <ROOT>
  <source>
    @type tail
    path "/path/to/data/test_utc/%Y%m%d_%H.json"
    pos_file "/path/to/pos/test_utc.pos"
    tag "test_utc"
    timezone "+00"
    <parse>
      @type "json"
    </parse>
  </source>
  <source>
    @type tail
    path "/path/to/data/test_jst/%Y%m%d_%H.json"
    pos_file "/path/to/pos/test_jst.pos"
    tag "test_jst"
    <parse>
      @type "json"
    </parse>
  </source>
  <match **>
    @type stdout
  </match>
</ROOT>
2019-12-10 13:48:19 +0900 [info]: starting fluentd-1.7.4 pid=64544 ruby="2.5.5"
...
2019-12-10 13:48:20 +0900 [info]: #0 following tail of /path/to/data/test_jst/20191210_13.json
2019-12-10 13:48:20 +0900 [info]: #0 following tail of /path/to/data/test_utc/20191210_04.json

I wrote a simple path, but is it correct to use Fluent::Timezone class?

Docs Changes:
None

Release Note:
None

@ganmacs
Copy link
Member

ganmacs commented Dec 10, 2019

It's reasonable for me to use Fluent::Timezone for such purpose.

@repeatedly ?

@repeatedly
Copy link
Member

Yes. Fluent::Timezone is better to handle timezone task.

@tatsu-yam
Copy link
Contributor Author

Thank you for reply.
I'll continue as it is and remove "Draft" after adding the following:

  • since option is only used to determine the path, change it from timezone to path_timezone or is there a better name?
  • add the same implementation to exclude_path
  • add test

If there are any problems, please point them out.

@ganmacs
Copy link
Member

ganmacs commented Dec 11, 2019

since option is only used to determine the path, change it from timezone to path_timezone or is there a better name?

Sounds good. I've thought same thing. path_timezone is better.

Could you follow the DCO https://github.com/fluent/fluentd/pull/2719/checks?check_run_id=341323383 ?(I think you know. it's just confirming)

@tatsu-yam
Copy link
Contributor Author

Could you follow the DCO https://github.com/fluent/fluentd/pull/2719/checks?check_run_id=341323383 ?(I think you know. it's just confirming)

Sure, I'll squash commits and sign off at that time.

@tatsu-yam tatsu-yam marked this pull request as ready for review December 16, 2019 15:06
Copy link
Contributor

@cosmo0920 cosmo0920 left a comment

Choose a reason for hiding this comment

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

:shipit:

@ganmacs
Copy link
Member

ganmacs commented Dec 19, 2019

Thank you!

@ganmacs ganmacs merged commit 6ef77be into fluent:master Dec 19, 2019
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.

4 participants