Method: Fluent::Plugin::ElasticsearchInput#create_time_parser
- Defined in:
- lib/fluent/plugin/in_elasticsearch.rb
#create_time_parser ⇒ Object
once fluent v0.14 is released we might be able to use Fluent::Parser::TimeParser, but it doesn’t quite do what we want - if gives
- sec,nsec
-
where as we want something we can call ‘strftime` on…
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/fluent/plugin/in_elasticsearch.rb', line 168 def create_time_parser if begin # Strptime doesn't support all formats, but for those it does it's # blazingly fast. strptime = Strptime.new() Proc.new { |value| value = convert_numeric_time_into_string(value, ) if value.is_a?(Numeric) strptime.exec(value).to_time } rescue # Can happen if Strptime doesn't recognize the format; or # if strptime couldn't be required (because it's not installed -- it's # ruby 2 only) Proc.new { |value| value = convert_numeric_time_into_string(value, ) if value.is_a?(Numeric) DateTime.strptime(value, ).to_time } end else Proc.new { |value| value = convert_numeric_time_into_string(value) if value.is_a?(Numeric) DateTime.parse(value).to_time } end end |