title: logstash check if field exists
body: <p>I have log files coming in to an ELK stack. I want to copy a field (foo) in order to perform various mutations on it, However the field (foo) isn't always present. </p>
  
  <p>If foo doesn't exist, then bar still gets created, but is assigned the literal string <code>"%{foo}"</code></p>
  
  <p>How can I perform a mutation only if a field exists? </p>
  
  <p>I'm trying to do something like this. </p>
  
  <pre><code>if ["foo"] {
    mutate {
      add_field =&gt; "bar" =&gt; "%{foo}
    }
  }
  </code></pre>