# Logstash pipeline multiple if statements

**URL:** <https://discuss.elastic.co/t/logstash-pipeline-multiple-if-statements/286737>\
**Category:** Logstash\
**Created:** [October 14, 2021, 2:25pm UTC](https://discuss.elastic.co/t/logstash-pipeline-multiple-if-statements/286737 "2021-10-14T14:25:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robin020](https://avatars.discourse-cdn.com/v4/letter/r/71c47a/32.png) [@Robin020](https://discuss.elastic.co/u/Robin020)\
**Post date:** [October 14, 2021, 2:25pm UTC](https://discuss.elastic.co/t/logstash-pipeline-multiple-if-statements/286737/1 "2021-10-14T14:25:19Z")

</div>

Hello,

I am trying create multiple if statements in the filter section in my pipeline config but I have no success with that.

This works (with one if statement)

```auto
filter {
  json {
      source => "message"
  }
  split { field => "[data][TABLE_neighbor][ROW_neighbor]" }

  if "172.1.1.1" in [host] or "172.1.1.2" in [host] or "172.1.1.3" in [host] or "172.1.1.4" in [host] {
      mutate {
          add_tag => ["test"]
      }
}
}

```

This doesn't work:

```auto
filter {
  json {
      source => "message"
  }
  split { field => "[data][TABLE_neighbor][ROW_neighbor]" }

  if "172.1.1.1" in [host] or "172.1.1.2" in [host] or "172.1.1.3" in [host] or "172.1.1.4" in [host] {
      mutate {
          add_tag => ["test"]
      }
}
  if "true" in [data.TABLE_neighbor.ROW_neighbor.up] {
      mutate {
           add_field => { "testfield" => "1" }
      }
}
}

```

What wrong with this filter? How can I use multiple if statements for different fields?

Regards,  
Robin

---

<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:** [October 15, 2021, 5:02pm UTC](https://discuss.elastic.co/t/logstash-pipeline-multiple-if-statements/286737/2 "2021-10-15T17:02:58Z")

</div>

> [@Robin020](#):
>
> `[data.TABLE_neighbor.ROW_neighbor.up]`

Your split filter suggests you have a field called [data][TABLE\_neighbor][ROW\_neighbor] (in elasticsearch or kibana you would call that data.TABLE\_neighbor.ROW\_neighbor) so it seems likely that your second if should be

```
if "true" in [data][TABLE_neighbor][ROW_neighbor][up] {

```

---

<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:** [November 12, 2021, 5:03pm UTC](https://discuss.elastic.co/t/logstash-pipeline-multiple-if-statements/286737/3 "2021-11-12T17:03:23Z")

</div>

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