toyama0919 / fluent-plugin-file-sprintf

MIT License
3 stars 2 forks source link

add sorting of output for ltsv #3

Open geosone opened 10 years ago

geosone commented 10 years ago

at the moment when you output via ltsv the sorting is the order in the json message if you for ex have used the parser plugin to split a message further you get a the order as about described.

it would be great to have a comma sepperated list whwre you can specify some ordering for some keywords

for ex i have in my json message these feilds time host logtag pid ident message source target .......

and it gest written as this line time:...\t logtag:....\t host:...\t message:...\t ident:...\t .... and so on but it schould look like this time: host: logtag: ident: message: .......

something like prefered_ltsv_order time,host,logtag,ident,message this will force the specified field to be the first in the list and all other will appere afterward.

toyama0919 commented 10 years ago

sorry! please Show me settings.

no problem this setting

<match custom_ltsv.sprintf>
  type file_sprintf
  buffer_path tmp/buffer/custom_ltsv.*.log
  path tmp/custom_ltsv.log
  format time:%s\tlogtag:%s\thost:%s\tmessage:%s\tident:%s
  key_names time,tag,host,message,ident
  flush_interval 10s
  include_time_key true
</match>

output result

time:2014-05-31 23:12:29    logtag:custom_ltsv.sprintf  host:web01  message:b   ident:hoge
time:2014-05-31 23:12:30    logtag:custom_ltsv.sprintf  host:web01  message:b   ident:hoge
time:2014-05-31 23:12:31    logtag:custom_ltsv.sprintf  host:web01  message:b   ident:hoge
time:2014-05-31 23:12:32    logtag:custom_ltsv.sprintf  host:web01  message:b   ident:hoge
time:2014-05-31 23:12:33    logtag:custom_ltsv.sprintf  host:web01  message:b   ident:hoge
geosone commented 10 years ago

but this way all the other lvts tags would not get added only the specifed would make it intoo the log

this request is to have a predefined order for some of the lvts tags and the rest would be added afterwards if i take your example it would look like this.

time:2014-05-31 23:12:29 logtag:custom_ltsv.sprintf host:web01 message:b ident:hoge source:192.168.x.x target:192.168.11.1 durration:45 .......

so the idea was to have a way to specify a sort of sorting for the ltsv tags (if present sort it this way) and add the rest ofterwards.