Split and Substring

Hello guys,
I have a group of strings like "lorem","ipsum", i wanna only "um" part of the string
how i can do it

i tried mutate filter and split, split give me array but i need last two char of the array
filter {
mutate {
split => ["message",","]
add_field => {"[@metadata][mykey]" => "%{[message][1]}"} //but i need [message][1][..2]
}
}

mutate { gsub => [ "[@metadata][mykey]", ".*(..)$", "\1" ] }

can not working or idk how to append this code.

What do you get from

output { stdout { codec => rubydebug } }

for a sample message?

input {
udp {
port => xxxx
}
}

filter{
mutate {
split => ["message",","]
add_field => {"[@metadata][mkey]" => "%{[message][1]}"}
# try to get last 2 char
}
}

output {
kafka {
codec => plain { format => '{"ip":"%{host}", "msg":"%{message}", "test":"%{[@metadata][mkey]}"}'}
topic_id => "test"
message_key => "%{[@metadata][mkey]}"
}
}

haven't any error but i get message from string %{[@metadata][mkey] not "um"

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