# Using conditionals to decide which logs to filter

**URL:** <https://discuss.elastic.co/t/using-conditionals-to-decide-which-logs-to-filter/198305>\
**Category:** Logstash\
**Created:** [September 5, 2019, 6:11pm UTC](https://discuss.elastic.co/t/using-conditionals-to-decide-which-logs-to-filter/198305 "2019-09-05T18:11:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sarahvo](https://avatars.discourse-cdn.com/v4/letter/s/f04885/32.png) [@sarahvo](https://discuss.elastic.co/u/sarahvo)\
**Post date:** [September 5, 2019, 6:11pm UTC](https://discuss.elastic.co/t/using-conditionals-to-decide-which-logs-to-filter/198305/1 "2019-09-05T18:11:25Z")

</div>

Hi, I'm using the beat utilities to ship logs to Logstash. I only want to parse the logs using the grok filter when it's coming from filebeat, but I can't seem to get it to work. The parsing works the way I want it to, but when I add the conditional, it doesn't go through.

Here's what my filter section looks like:

```
filter {
  if [input.type] == "log" {
    grok {
      match => { "message" => "%{TIMESTAMP_ISO8601:ltm.timestamp}\s%{SYSLOGHOST:ltm.name}\s%{LOGLEVEL:log.level}\s%{PROG:program}(?:\[%{POSINT:pid}\])?:\s%{GREEDYDATA:ltm.message}" }
    }
    date {
      match => ["time", "ISO8601"]
    }
  }	
}

```

Any insight on how to use the conditional correctly would be greatly appreciated! Thanks!

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [September 5, 2019, 6:13pm UTC](https://discuss.elastic.co/t/using-conditionals-to-decide-which-logs-to-filter/198305/2 "2019-09-05T18:13:21Z")

</div>

[input.type] refers to a field with a period in the name. You probably want the type field within the input object, which would be [input][type]

---

<div class="post-metadata">

**Author:** ![sarahvo](https://avatars.discourse-cdn.com/v4/letter/s/f04885/32.png) [@sarahvo](https://discuss.elastic.co/u/sarahvo)\
**Post date:** [September 5, 2019, 6:17pm UTC](https://discuss.elastic.co/t/using-conditionals-to-decide-which-logs-to-filter/198305/3 "2019-09-05T18:17:14Z")

</div>

Works now! Thanks!

---

<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:** [October 3, 2019, 6:17pm UTC](https://discuss.elastic.co/t/using-conditionals-to-decide-which-logs-to-filter/198305/4 "2019-10-03T18:17:15Z")

</div>

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