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

file timezone problem #1986

Closed
f-ueno opened this issue May 16, 2018 · 10 comments
Closed

file timezone problem #1986

f-ueno opened this issue May 16, 2018 · 10 comments

Comments

@f-ueno
Copy link

f-ueno commented May 16, 2018

Fluentd version: td-agent 1.0.2

I want to transfer logfile from CentOS to CentOS by fluentd.
I could transfer file but file switches at incorrect time.
My timezone is +0900.

  • output files (ls -l)
    rw-r--r-- 1 root root 34201618 5月 15 09:02 test-log.20180514
    rw-r--r-- 1 root root 40060437 5月 16 09:01 test-log.20180515
    rw-r--r-- 1 root root 5943936 5月 16 10:47 test-log.20180516

I want files switch at 00:00 but actually they switch at 09:00 everyday.
When I set time_slice_format = %Y%m%d_%H files switch correctly. (test.log.20180516_01 is created at 01:00 )

how can I solve it?

config (input) :

<source>
 type tail
 format none
 path /var/log/test-log
 pos_file /var/log/td-agent/test-log.pos
 tag hostfrom.test-log
</source>

<match *.*>
 type forward
 <server>
  host hostlog
  port 24224
 </server>
</match>

config (output) :

<source>
 @type forward
 bind 0.0.0.0
 port 24224
</source>

<match hostfrom.test-log>
 type file
 format single_value
 buffer_path /var/log/td-agent/buffer/test-log.buf
 path /log/test-log
 append true
 path_suffix
</match>
@luweiv9988
Copy link

i got same issue

@repeatedly
Copy link
Member

The problem is %Y%m%d time rage causes incorrect time but %Y%m%d%Htime range has no problem, right?

@f-ueno
Copy link
Author

f-ueno commented May 21, 2018

Yes, %Y%m%d only happens.

@repeatedly
Copy link
Member

Okay, will check.
For workaround, you can use timekey 3600 in <buffer> and %Y%m%d in the path.

@f-ueno
Copy link
Author

f-ueno commented May 21, 2018

For workaround, you can use timekey 3600 in and %Y%m%d in the path.

It did not work because of config error.

[error]: config error file="/etc/td-agent/td-agent.conf" error_class=Fluent::ConfigError error="insufficient timestamp placeholders in path"

%Y%m%d%H in the path worked with timekey 3600

@luweiv9988
Copy link

@f-ueno I try to set %Y%m%d%H in path, but getting configure error...

<match message.*>
  @type file
  path /tmp/messages/transfer.${tag[1]}.%Y-%m-%d.%H%M.log
  compress gzip
  append true
  <buffer tag,time>
    @type file
    path /tmp/buffer/message
    timekey     1d
    timekey_wait 0
    flush_mode interval
    flush_interval 86400
  </buffer>
</match>

@f-ueno
Copy link
Author

f-ueno commented May 21, 2018

@luweiv9988 I think you should use correct path depending on timekey

%Y%m%d with timekey 1d
%Y%m%d%H with timekey 1h
%Y%m%d%H%M with timekey 1m

@repeatedly
Copy link
Member

It seems time calculation with larger timekey has bug.
I'm now trying to fix the problem.

@f-ueno
Copy link
Author

f-ueno commented May 30, 2018

@repeatedly do you have any workaround if the problem is not fixed ?

okkez added a commit to okkez/fluentd that referenced this issue Jul 5, 2018
Because the timestamp of the midnight cannot be divisible by 86400 in
localtime (JST). The timestamp of the midnight is divisible by 86400
only in UTC. Therefore we must consider offset from UTC in localtime.

For example, at `2018-07-04 01:23:23 +0900`:

If timekey is 86400 and path template is `/log/%Y%m%d.log`.
In previous version, extract path template to `/log/20180703.log`.
In this version, extract path template to `/log/20180704.log`.

Fix fluent#1986

Signed-off-by: Kenji Okimoto <okimoto@clear-code.com>
@okkez
Copy link
Contributor

okkez commented Jul 5, 2018

@f-ueno Could you try #2054?

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

No branches or pull requests

4 participants