# Filebeat filter message for specific path

**URL:** <https://discuss.elastic.co/t/filebeat-filter-message-for-specific-path/115954>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [January 17, 2018, 11:20pm UTC](https://discuss.elastic.co/t/filebeat-filter-message-for-specific-path/115954 "2018-01-17T23:20:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![saikrishnagaddipati](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@saikrishnagaddipati](https://discuss.elastic.co/u/saikrishnagaddipati)\
**Post date:** [January 17, 2018, 11:20pm UTC](https://discuss.elastic.co/t/filebeat-filter-message-for-specific-path/115954/1 "2018-01-17T23:20:59Z")

</div>

Hi , I am using filebeat-5.6.3  
with the below filebeat config  
i am able to

- drop the events which doesn't have "testing2" or "testing1" in the message field of path  
"/var/log/messages"
- drop the events which doesn't have "testing2" or "testing1" in the message field of path  
"/var/log/websphere/websphere.log".

I want to

- drop events which doesn't contain "testing2" only in message field of path "/var/log/messages"
- similarly drop events which doesn't contain "testing1" only in the message field of path  
"/var/log/websphere/websphere.log".

Please suggest how to achieve this.

```
filebeat:
  prospectors:
  - input_type: log
    paths:
    - "/var/log/messages"
    fields:
      type: syslog
    fields_under_root: true
  - input_type: log
    paths:
    - "/var/log/websphere/websphere.log"
    fields:
      type: syslog
    fields_under_root: true
processors:
- drop_event:
    when.not:
      or:
      - regexp:
          message: testing2
      - regexp:
          message: testing1
```

---

<div class="post-metadata">

**Author:** ![kvch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kvch/32/72058_2.png) [@kvch](https://discuss.elastic.co/u/kvch)\
**Post date:** [January 18, 2018, 11:58am UTC](https://discuss.elastic.co/t/filebeat-filter-message-for-specific-path/115954/2 "2018-01-18T11:58:13Z")

</div>

You can match the path of your log file using `source`: [https://www.elastic.co/guide/en/beats/filebeat/6.1/exported-fields-log.html#\_literal\_source\_literal](https://www.elastic.co/guide/en/beats/filebeat/6.1/exported-fields-log.html#_literal_source_literal)

Let me know if the following works for you:

```auto
processors:
- drop_event:
   when:
      or:
      - and:
        - not.regexp.message: testing2
        - equals.source: /var/log/messages
      - and:
        - not.regexp.message: testing1
        - equals.source: /var/log/websphere/websphere.log

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 15, 2018, 11:58am UTC](https://discuss.elastic.co/t/filebeat-filter-message-for-specific-path/115954/3 "2018-02-15T11:58:27Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
