I need dynamically generated fields based on the CSV in the logs.
In this case my csv format can be in any of the following ways:
CSV =
CSV = 0
CSV = 1111;2222;3333;4444444;5555
CSV = 1;2;3;4;5;6;7;8;9;10
So, I want the fields to be created in the following way:
CSV01 = 1
CSV02 = 2
CSV03 = 3
.
.
.
For this I tired the following Ruby code in filter plugin
ruby {
code => '
if event.get("CSV") != ""
CSV_Numbers = event.get("CSV").split(";")
for csvNumber in CSV_Numbers
IndexValue = event.get("CSV").index("csvNumber")
fieldName = event.set("CSV0" + IndexValue)
event.set("fieldName", csvNumber)
end
end
'
}
But I'm not able to generate fields dynamically. Can someone please help me in this case.