# Exclude path at .conf file

**URL:** <https://discuss.elastic.co/t/exclude-path-at-conf-file/173122>\
**Category:** Logstash\
**Created:** [March 20, 2019, 10:58am UTC](https://discuss.elastic.co/t/exclude-path-at-conf-file/173122 "2019-03-20T10:58:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![manosmustang](https://avatars.discourse-cdn.com/v4/letter/m/ecc23a/32.png) [@manosmustang](https://discuss.elastic.co/u/manosmustang)\
**Post date:** [March 20, 2019, 10:58am UTC](https://discuss.elastic.co/t/exclude-path-at-conf-file/173122/1 "2019-03-20T10:58:32Z")

</div>

Hello,

I have the below netdata.conf file and i want to exclude the path /var/log/messages

```
[root@centos conf.d]# cat netdata.conf
input {
    beats {
        port => 5044
     }
    } 
output {
 elasticsearch {
    hosts => ["localhost:9200"]
    index => "netdatalogs"
  }
stdout { codec => rubydebug }
}

```

Any ideas?

Thank you

---

<div class="post-metadata">

**Author:** ![BennyInc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bennyinc/32/21751_2.png) [@BennyInc](https://discuss.elastic.co/u/BennyInc)\
**Post date:** [March 21, 2019, 1:16pm UTC](https://discuss.elastic.co/t/exclude-path-at-conf-file/173122/2 "2019-03-21T13:16:32Z")

</div>

So you get data from a beat (filebeat?) but don't want to push the events to elasticsearch/stdout if the path is /var/logs/messages? I would assume your beat should store the path in a field, e.g. "source". You can then [use conditionals](https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#conditionals) to only use the outputs if that path is not given:

```
output {
  if [source] != "/var/logs/messages" {
    elasticsearch {
      hosts => ["localhost:9200"]
      index => "netdatalogs"
    }
    stdout { codec => rubydebug }
  }
}
```

---

<div class="post-metadata">

**Author:** ![BKG](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bkg/32/43591_2.png) [@BKG](https://discuss.elastic.co/u/BKG)\
**Post date:** [March 21, 2019, 2:14pm UTC](https://discuss.elastic.co/t/exclude-path-at-conf-file/173122/3 "2019-03-21T14:14:13Z")

</div>

you would need something like

```
filter {
    if [log][file][path] == "/var/log/messages" { drop{} }
}
```

---

<div class="post-metadata">

**Author:** ![manosmustang](https://avatars.discourse-cdn.com/v4/letter/m/ecc23a/32.png) [@manosmustang](https://discuss.elastic.co/u/manosmustang)\
**Post date:** [March 22, 2019, 9:27am UTC](https://discuss.elastic.co/t/exclude-path-at-conf-file/173122/4 "2019-03-22T09:27:41Z")

</div>

and what if I want to add another if?

filter {  
if [log][file][path] == "/var/log/messages" { drop{} }  
if [log][file][path] == "/var/log/secure" { drop{} }  
}

is this correct?

thank you

---

<div class="post-metadata">

**Author:** ![manosmustang](https://avatars.discourse-cdn.com/v4/letter/m/ecc23a/32.png) [@manosmustang](https://discuss.elastic.co/u/manosmustang)\
**Post date:** [March 22, 2019, 11:19am UTC](https://discuss.elastic.co/t/exclude-path-at-conf-file/173122/5 "2019-03-22T11:19:49Z")

</div>

thanks BKG it worked!

---

<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:** [April 19, 2019, 11:19am UTC](https://discuss.elastic.co/t/exclude-path-at-conf-file/173122/6 "2019-04-19T11:19:54Z")

</div>

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