# Logstash filter "if" condition to check if field exist or not

**URL:** <https://discuss.elastic.co/t/logstash-filter-if-condition-to-check-if-field-exist-or-not/268336>\
**Category:** Logstash\
**Created:** [March 25, 2021, 12:15pm UTC](https://discuss.elastic.co/t/logstash-filter-if-condition-to-check-if-field-exist-or-not/268336 "2021-03-25T12:15:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ankitdevnalkar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ankitdevnalkar/32/46158_2.png) [@ankitdevnalkar](https://discuss.elastic.co/u/ankitdevnalkar)\
**Post date:** [March 25, 2021, 12:15pm UTC](https://discuss.elastic.co/t/logstash-filter-if-condition-to-check-if-field-exist-or-not/268336/1 "2021-03-25T12:15:37Z")

</div>

Is there any way in Logstash to check if a certain field exists or not?

My use-case:  
I want to add a field "status: missing" when the field "httpStatus" doesn't come in the log document.

---

<div class="post-metadata">

**Author:** ![grumo35](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/grumo35/32/59451_2.png) [@grumo35](https://discuss.elastic.co/u/grumo35)\
**Post date:** [March 25, 2021, 2:20pm UTC](https://discuss.elastic.co/t/logstash-filter-if-condition-to-check-if-field-exist-or-not/268336/2 "2021-03-25T14:20:14Z")

</div>

Hi,

You can try this:

```auto
if ! [httpStatus] {}

```

---

<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 22, 2021, 2:20pm UTC](https://discuss.elastic.co/t/logstash-filter-if-condition-to-check-if-field-exist-or-not/268336/3 "2021-04-22T14:20:49Z")

</div>

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