A Fluentd filter plugin to cast record types
Fluentd >= v0.12
Use RubyGems:
gem install fluent-plugin-filter_typecast
<source>
type dummy
tag dummy
dummy {"field1":"1","field2":"2","field3":"2013-02-12 22:04:14 UTC","field4":"true","field5":"a,b,c"}
</source>
<filter **>
type typecast
types field1:integer,field2:string,field3:time,field4:bool,field5:array
</filter>
<match **>
type stdout
</match>
You should see casted records:
dummy {"field1":1,"field2":"2","field3":1418380657,"field4":true,"field5":["a","b","c"]}
- types
- KEY:TYPE pairs separated by comma(,)
- support types:
- integer
- float
- string
- time
- bool
- array
Time format can be specified like KEY:time:TIME_FORMAT
as:
<filter **>
type typecast
types field3:time:%d/%b/%Y:%H:%M:%S %z
</filter>
As default, ruby takes cares of it as much as possible (Time.parse
method is used).
The output becomes an integer (epoch time).
Array delimiter can be specified like KEY:array:DELIMITER
as:
<filter **>
type typecast
types field5:array:.
</filter>
See CHANGELOG.md for details.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Copyright (c) 2015 Naotoshi Seo. See LICENSE for details.