# Logstash使用if做条件判断问题

**URL:** <https://discuss.elastic.co/t/logstash-if/203544>\
**Category:** Logstash\
**Created:** [October 15, 2019, 2:02am UTC](https://discuss.elastic.co/t/logstash-if/203544 "2019-10-15T02:02:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shenshensinian](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@shenshensinian](https://discuss.elastic.co/u/shenshensinian)\
**Post date:** [October 15, 2019, 2:02am UTC](https://discuss.elastic.co/t/logstash-if/203544/1 "2019-10-15T02:02:07Z")

</div>

你好，我在filter阶段使用if语句做条件判断的时候出现if语句无效果，也没有报错。版本7.1.1 例句如下。

filter {  
if [message] in ["te1","bb","lkj","hetyafaef"]  
grok{  
match =\> {"message" =\> "\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*"}  
}  
}

---

<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, 2019, 2:16pm UTC](https://discuss.elastic.co/t/logstash-if/203544/2 "2019-10-15T14:16:00Z")

</div>

> [@shenshensinian](#):
>
> if [message] in ["te1","bb","lkj","hetyafaef"]

That array membership test is equivalent to

```
if ([message] == "te1") or ([message] == "bb") or ([message] == "lkj") or ([message] == "hetyafaef")

```

Is that what you want?

---

<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, 2019, 2:16pm UTC](https://discuss.elastic.co/t/logstash-if/203544/3 "2019-11-12T14:16:04Z")

</div>

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