Using Ruby to count the number of fields in a message, then apply CSV depending on the count?

You can count the fields using ruby

ruby { code => 'event.set("[@metadata][fields]", 1 + event.get("message").count(","))' }
if [@metadata][fields] == 73 {
     csv { ... }
} else {
     csv { ... }
}
2 Likes