Get the field count of a csv file

Sample CSV file

2018-03-05 21:29:31 -0500|188c9263-2519-4a8d-825c-4605c53b720e|email|1000|0|7702831801|start|89029287801|1273721801|end

2018-03-05 21:23:10 -0500|23k8w23y-27k3-293s-le22-825c29l23us2|fax|21000|0|2389231|282830282|92903-109281-3628|89029287801|1273721801|22po39|starttime|endtime|success

Which filter can get the field count

The first line has 10 fields & the second has 15 fields

Not familiar with ruby, however managed to get the field count using the ruby filter

filter {

   ruby {  code => 'event.set("[@metadata][field_count]", event.get("message").split("|").count())'  }
 }
1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.