I have a simple request but seem unable to be able execute it correctly.
I have a field named logname that has several name forms. For instance are logname-app, logname-os, logname-access, and logname. The logname is variable. The goal is to produce a variable logname in the path without the ending -app, -acess -os, etc and to use this in a logstash prefix. For instance, I would like to end with:
prefix => "%{+YYYY]/%{+MM}/%{+dd}/%{[sublog]}/application
prefix => "%{+YYYY]/%{+MM}/%{+dd}/%{[sublog]}/os
prefix => "%{+YYYY]/%{+MM}/%{+dd}/%{[sublog]}/access...etc.
I have the if statement working correctly based on the presence of the end of the field for instance.... if "-app" in [logname]....then moved data to and produce the one of the varients of the prefix above....
I most recently tried
filter {
if "-app" in [logname] [
mutate {
add field => {
"[sublog] => "%{[logname]}" }
remove_field => "-app"
the above does not work.
What I cannot get working is the filter or whatever to not only create the new sublog from the [logname], but remove the -app, etc from the newly formed sublog field so I can correctly insert the new sublog into the prefix without the -app at the end . Any help would be appreciated