title: Logstash: how to add file name as a field?
body: <p>I'm using Logstash + Elasticsearch + Kibana to have an overview of my Tomcat log files.</p>
  
  <p>For each log entry I need to know the name of the file from which it came. I'd like to add it as a field. Is there a way to do it?
  I've googled a little and I've only found <a href="https://stackoverflow.com/questions/12346590/getting-timestamp-of-event-from-file-name-in-logstash">this SO question</a>, but the answer is no longer up-to-date.</p>
  
  <p>So far the only solution I see is to specify separate configuration for each possible file name with different "add_field" like so:</p>
  
  <pre><code>input {
    file {
       type =&gt; "catalinalog"
       path =&gt; [ "/path/to/my/files/catalina**" ]
       add_field =&gt; { "server" =&gt; "prod1" }
    }
  }
  </code></pre>
  
  <p>But then I need to reconfigure logstash each time there is a new possible file name.
  Any better ideas?</p>