title: Logstash filter, if field matches regex not working
body: <p>In my Logstash pipeline I want to apply some operations to a field if it matches a regex. For example I want to filter all <code>url</code> fields that start with <code>JOB:</code> so after researching I came up with this config:</p>
  
  <pre><code>filter {
          grok {
              patterns_dir =&gt; ["./patterns"]
                    if [url] =~ /^JOB: .*/ {
                         add_field =&gt; {
                                "job_type" =&gt; "JOB: %{job_type:url}"
                         }
                    }
           }
  }
  </code></pre>
  
  <p>But after running <code>service logstash configtest</code> I get this error:</p>
  
  <pre><code>The given configuration is invalid. Reason: 
  Expected one of #, =&gt; at line 87, column 7 (byte 3332) after filter {
                          grok {
                                  patterns_dir =&gt; ["./patterns"]
                                  if 
  </code></pre>