Filter mutate replace field value with value of another field


(Chris Clifton) #1

Hoping this is a simple syntax issue,

I'm adding a tag to events from filebeat on the client shipper,

 fields:
     tag_hostname: "Dev Server"

host value is already present in LS, I want to replace the value of the host field with the value in fields.tag_hostname,

 filter {
 mutate {
    update => { "host" => "[fields.tag_hostname]" }
     }
 }

I've tried all manner of syntax, ("host" => "%{fields.tag_hostname}" , "host" => "%{[fields.tag_hostname}]" etc , none seem to work, host field keeps being replaced with the literal of whatever is between the quotes. Tried without quotes, of course that doesn't work.


(Magnus B├Ąck) #2
filter {
  mutate {
    update => { "host" => "%{[fields][tag_hostname]}" }
  }
 }

See https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#logstash-config-field-references and the following section.


(Chris Clifton) #3

awesome! that's what I was looking for, thanks for the quick reply!


(system) #4