Set default timezone on tail_in

984 views
Skip to first unread message

phil...@mybasis.com

unread,
Feb 5, 2015, 8:27:51 PM2/5/15
to flu...@googlegroups.com
Hi,

Is there a way to specify the default timezone on tail_in? I have logs that have timestamps in the format "150205 11:12:13" with no timezone. Currently it seems like fluentd sets the timezone to the same as the systems. Can I have it default to UTC?

ex. config:

<source>
  type tail
  path foo.log
  format (?<time>.*)
  time_format %y%m%d %H:%M:%S
</source>

Thanks

Kiyoto Tamura

unread,
Feb 5, 2015, 9:06:19 PM2/5/15
to flu...@googlegroups.com
phibert-

I just looked at the code, and I don't "default" timezone is supported right now. Underneath, Fluentd calls Ruby's Time#strptime method with time_format against the time string.

Come to think of it, this is not a bad feature to have.

Meanwhile, you can keep the time in "localtime" throughout and use the formatter plugin to format the output. Do you think that would meet your needs? > http://docs.fluentd.org/articles/formatter-plugin-overview

Kiyoto

--
You received this message because you are subscribed to the Google Groups "Fluentd Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fluentd+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Check out Fluentd, the open source data collector to unify log management.

phil...@mybasis.com

unread,
Feb 5, 2015, 11:24:49 PM2/5/15
to flu...@googlegroups.com
The formatter plugin only changes the presentation of the timestamp, and not the actual value correct? I can use the record_reformer to add the value to another key (such as "enable_ruby true"; "time ${(time + HOURS_OFFSET * 60 * 60).strftime(<FORMAT>)}").  I was hoping for something simpler but this should work.

Thanks!

Kiyoto Tamura

unread,
Feb 5, 2015, 11:36:41 PM2/5/15
to flu...@googlegroups.com
Philbert-

>The formatter plugin only changes the presentation of the timestamp, and not the actual value correct? I can use the record_reformer to add the value to another key (such as "enable_ruby true"; "time ${(time + HOURS_OFFSET * 60 * 60).strftime(<FORMAT>)}").  I was hoping for something simpler but this should work.

You are right about formatter: it still represents the time locally internally, so you would need to be careful when using TimeSlicedOutput like out_s3 and out_file.

One thing to note about record_reformer (or in v0.12, record_transformer filter) is that it still canNOT change the time value of the event: it merely adds a field to the record, i.e., if you had a Fluentd event (tag, time, record) like

(foo.bar, Time(2015-01-01 00:00:00 +08:00:00), {"hello":"world"})

then, even doing what you said, you would get

(foo.bar, Time(2015-01-01 00:00:00 +08:00:00), {"hello":"world", "time":Time(2015-01-01 00:00:00 UTC)})

Just curious: what are your data sources/outputs?

Kiyoto


Reply all
Reply to author
Forward
0 new messages