amirfarsi
(Amirhossein Farsijani)
September 20, 2022, 7:29am
1
Hello friends.
I have a list of lists in the form below:
doc 1:
[[40004, 10], [40005, 12]]
doc 2:
[[40004, 8], [40006, 12], [20002, 3]]
I want to change them to the following form:
doc 1:
{
"40004": 10,
"40005": 12
}
doc 2:
{
"40004": 8,
"40006": 12,
"20002": 3
}
How can I do this with logstash filter ?
Thanks
Badger
September 20, 2022, 12:10pm
2
You will need to use a ruby filter, something similar to this .
amirfarsi
(Amirhossein Farsijani)
September 24, 2022, 12:52pm
3
I solved the problem in the following way:
mutate {
gsub => [
## handeling multiple items
"items", "\]\,", "-", ### [[40004, 10- [40005, 12]]
## removing extra characteres
"items", "[\[\]]", "", ### 40004, 10- 40005, 12
"items", "\s", "" ### 40004,10-40005,12
]
}
kv {
source => "items"
field_split => "-"
value_split => ","
prefix => "item_"
}
Thanks @Badger
system
(system)
Closed
October 22, 2022, 12:53pm
4
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.