Hi everyone,
I'm trying to do something with fluentd :
I want to read csv files in a specific format.
"2015/03/06","10:15:06","005067A3D837","65532","1","1","2","1"
My first problem :
I use tail to read them as follow :
<source>
type tail
read_from_head true
path /home/toto/fluentd/csvin/*/*/*.csv
tag csvin.*
pos_file /home/toto/fluentd/csvin/position
format
/^(?<time>"20\d{2}/(1[0-2]|0\d)/([0-2]\d|3[01])","([01]\d|2[0-3]):[0-5]\d:[0-5]\d"),"(?<mac>[0-9A-F]{12})","(?<kwh>\d+)","(?<site>\d+)","(?<terminal>\d+)","(?<zone>\d+)","(?<ballast>\d+)"$/
</source>
<match csvin.**>
type file
path /home/toto/fluentd/fileout/fluentd_output
format json
include_time_key true
</match>
It work very well (I actually send the rows to a mysql database etc ...) but the thing is I have to keep the not matched rows.
for example if I get the following record
"2015/03/06","10:15:06","005067A3D837","65532","1","1","2","BANANA"
I want to send this not matched row to a different database.
For example look at this :
<source>
type tail
read_from_head true
path /home/toto/fluentd/csvin/*/*/*.csv
tag raw.csvin.*
pos_file /home/toto/fluentd/csvin/position
format none
</source>
<match raw.csvin.**>
type parser
remove_prefix raw
key_name message
format
/^(?<time>"20\d{2}/(1[0-2]|0\d)/([0-2]\d|3[01])","([01]\d|2[0-3]):[0-5]\d:[0-5]\d"),"(?<mac>[0-9A-F]{12})","(?<kwh>\d+)","(?<site>\d+)","(?<terminal>\d+)","(?<zone>\d+)","(?<ballast>\d+)"$/
</match>
<match csvin.**>
type file
path /home/toto/fluentd/fileout/fluentd_output
format json
include_time_key true
</match>
<match failed.raw.csvin.**>
type file
path /home/toto/fluentd/fileout/different_output
format json
include_time_key true
</match>
Do you know any way or any plugin who can do that ?
I have tried parser, grep, etc ...
I would need something like this :
<match raw.csvin.**>
type ?????
remove_prefix raw
format
/^(?<time>"20\d{2}/(1[0-2]|0\d)/([0-2]\d|3[01])","([01]\d|2[0-3]):[0-5]\d:[0-5]\d"),"(?<mac>[0-9A-F]{12})","(?<kwh>\d+)","(?<site>\d+)","(?<terminal>\d+)","(?<zone>\d+)","(?<ballast>\d+)"$/
reemit_not_matched true
reemit_tag_prefixe failed
</match>
I have found "assert" but it no longer work.
Thanks for your time and sry for my english
NB : I know I can do it by capturing my logs with fluent.** and grep them but i want to find a proper way.
2015-03-09 10:42:56 +0100 [warn]: plugin/out_parser.rb:82:block (2 levels) in emit: pattern not match with data '"2015/03/06","04:45:06","005067A3D837","cacao","1","1","2","1"'