# Change Nil values to set default value

**URL:** <https://discuss.elastic.co/t/change-nil-values-to-set-default-value/328369>\
**Category:** Logstash\
**Created:** [March 23, 2023, 4:22pm UTC](https://discuss.elastic.co/t/change-nil-values-to-set-default-value/328369 "2023-03-23T16:22:36Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [March 23, 2023, 4:55pm UTC](https://discuss.elastic.co/t/change-nil-values-to-set-default-value/328369/2 "2023-03-23T16:55:59Z")

</div>

> [@rubhamra](#):
>
> Logstash is dropping fields which has "nil" values, but I don't want those fields to be drop

Can you provide more context? Logstash does not drop field unless you have a mutate with the remove\_field telling it to remove the field.

If the value is nil, it will output as nil.

Also, your code will only work for top level fields, it is a similar issue as your [previous question](https://discuss.elastic.co/t/remove-specific-field-matching-pattern/328260/4).

You probably could rework that code to do what you want.

---

_[View the full topic](https://discuss.elastic.co/t/change-nil-values-to-set-default-value/328369)._
