I have 1 sample transaction number 10004567-P658910-569876.
I want to seperate above transaction number with index 0 as 1 seperate field and remaining as other field.
Ex: 10004567-P658910-569876
Num_field = 10004567
Remaining_field = P658910-569876
I tried using mutate split method. I am unable to loop over array.
Below is the snippet I have tried:
mutate {
split => { "doc_number" => "-" }
ruby {
** code => '**
** ids = event.get("doc_number")**
** ids.each_with_index do |value, index|**
** if index[0]**
** event.set("[doc_number]",value)**
** end **
** end**
** '**
** }**
}
Could you please @magnusbaeck help me out?
Thanks.