Logstash: If message contains regex add field

Hello,

within my Logstash config I'm searching for a regex pattern. If a logfile is found which matches the regex a new field should be added with the found pattern.
The if statement is working but I don't know how to save the exact pattern to a new field. This is my code at the moment:

input {
  stdin { }
}

filter {
  if [message] =~ "[0-9|A-Z]{11}" {
    mutate {
      add_field => {"message-id" => "found pattern from above" }
    }
  }

output {
  stdout { codec => rubydebug }
}

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