# Logstash not showing field with null values

**URL:** https://discuss.elastic.co/t/logstash-not-showing-field-with-null-values/338648
**Category:** Logstash
**Created:** [July 18, 2023, 9:45am UTC](https://discuss.elastic.co/t/logstash-not-showing-field-with-null-values/338648 "2023-07-18T09:45:23Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Mohit\_Gupta2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohit_gupta2/32/123579_2.png) [@Mohit\_Gupta2](https://discuss.elastic.co/u/Mohit_Gupta2)
#### Post date: [July 18, 2023, 9:45am UTC](https://discuss.elastic.co/t/logstash-not-showing-field-with-null-values/338648/1 "2023-07-18T09:45:23Z")

</div>

I am indexing elasticsearch via logstash but it is showing only document's fields with not null values.  
Earlier I used to do this through transporter and it returns the null values as well. Also the mapping in both cases (transporter and logstash) is same.  
Mongo --\> Elasticsearch  
eg - earlier response was [{"name":"xyz",city:null,"age":50,"additional\_info":null}] now it is [{"name":"xyz","age":50}]

---

<div class="post-metadata">

### Author: ![Mohit\_Gupta2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohit_gupta2/32/123579_2.png) [@Mohit\_Gupta2](https://discuss.elastic.co/u/Mohit_Gupta2)
#### Post date: [July 18, 2023, 11:31am UTC](https://discuss.elastic.co/t/logstash-not-showing-field-with-null-values/338648/3 "2023-07-18T11:31:59Z")

</div>

thanks for the quick response but I find that there is no output plugin like include\_null\_fields =\> true in logstash. can you suggest something further

---

<div class="post-metadata">

### Author: ![Mohit\_Gupta2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohit_gupta2/32/123579_2.png) [@Mohit\_Gupta2](https://discuss.elastic.co/u/Mohit_Gupta2)
#### Post date: [July 18, 2023, 12:17pm UTC](https://discuss.elastic.co/t/logstash-not-showing-field-with-null-values/338648/4 "2023-07-18T12:17:41Z")

</div>

thanks for the quick response but I find that there is no output plugin like include\_null\_fields =\> true in logstash. can you suggest something further

---

<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: [July 18, 2023, 12:22pm UTC](https://discuss.elastic.co/t/logstash-not-showing-field-with-null-values/338648/5 "2023-07-18T12:22:15Z")

</div>

> [@PodarcisMuralis](#):
>
> Logstash by default will not index fields that have a null value. This is because Logstash is designed to be a lightweight tool for ingesting data, and indexing null values can add unnecessary overhead.

This is not correct, Logstash will not remove any field by default.

> [@Mohit\_Gupta2](#):
>
> I find that there is no output plugin like include\_null\_fields =\> true in logstash

Not sure where this come from, but there is no such option in the elasticsearch output in Logstash.

> [@Mohit\_Gupta2](#):
>
> can you suggest something further

Please share your entire Logstash configuration and a sample of your message, also are you combining Logstash with any module of Filebeat for example?

---

<div class="post-metadata">

### Author: ![Mohit\_Gupta2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohit_gupta2/32/123579_2.png) [@Mohit\_Gupta2](https://discuss.elastic.co/u/Mohit_Gupta2)
#### Post date: [July 18, 2023, 12:36pm UTC](https://discuss.elastic.co/t/logstash-not-showing-field-with-null-values/338648/6 "2023-07-18T12:36:55Z")

</div>

```auto
input {
  mongodb {
    uri => "mongo_uri"
    placeholder_db_dir => "/usr/share/logstash/"
    placeholder_db_name => "logstash_sqlite.db"
    collection => "test"
    batch_size => 50000
  }
}

 

filter {
  mutate {
    remove_field => ["_id"]
  }
}
output {
  elasticsearch {
    hosts => ["http://ip:9200/"]
    index => "test"
  }

```

---

<div class="post-metadata">

### Author: ![Mohit\_Gupta2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mohit_gupta2/32/123579_2.png) [@Mohit\_Gupta2](https://discuss.elastic.co/u/Mohit_Gupta2)
#### Post date: [July 18, 2023, 12:44pm UTC](https://discuss.elastic.co/t/logstash-not-showing-field-with-null-values/338648/7 "2023-07-18T12:44:26Z")

</div>

```auto
{
                "_index": "test",
                "_id": "U2DOaIkBXYO636wKiXYo",
                "_score": 14.1151085,
                "_ignored": [
                    "log_entry.keyword"
                ],
                "_source": {
                    "mongo_id": "626943c4f7c76a6b553aa982",
                    "source_type": "__",
                    "img_link": "some source",
                    "logdate": "2022-04-27T13:23:16+00:00",
                    "uuid": "626943c4f7c76a6b553aa982",
                    "sources": "some source",
                    "full_name": "abc",
                    "designation": "xyz",
                    "profile_category": "__",
                    "log_entry": "{\"_id\"=>BSON::ObjectId('626943c4f7c76a6b553aa982'), \"created_date_time\"=>nil, \"profile_category\"=>\"abc\", \"Prefix\"=>nil, \"full_name\"=>\"abc\", \"first_name\"=>nil, \"last_name\"=>nil, \"native_name\"=>nil, \"birth_name\"=>nil, \"aliases\"=>[\"\"], \"gender\"=>nil, \"dob\"=>nil, \"age\"=>nil, \"birth_place\"=>nil, \"citizen_country\"=>[\"__\"], \"education\"=>nil, \"occupation\"=>nil, \"designation\"=>\"xyz\", \"positions_held\"=>nil, \"residence\"=>nil, \"sources\"=>\"something\", \"father\"=>nil, \"mother\"=>nil, \"siblings\"=>nil, \"spouse\"=>nil, \"children\"=>nil, \"relatives\"=>nil, \"wikipedia_link\"=>nil, \"img_link\"=>\"some link\"}",
                    "@timestamp": "2023-07-18T11:41:51.924906714Z",
                    "host": "2c2d8b232f8f",
                    "@version": "1"
                }

```

---

<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: [August 15, 2023, 12:44pm UTC](https://discuss.elastic.co/t/logstash-not-showing-field-with-null-values/338648/8 "2023-08-15T12:44:58Z")

</div>

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