# Ingest Specific Json fields to Elastichsearch

**URL:** <https://discuss.elastic.co/t/ingest-specific-json-fields-to-elastichsearch/110324>\
**Category:** Logstash\
**Created:** [December 5, 2017, 11:03am UTC](https://discuss.elastic.co/t/ingest-specific-json-fields-to-elastichsearch/110324 "2017-12-05T11:03:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mussa572](https://avatars.discourse-cdn.com/v4/letter/m/a698b9/32.png) [@mussa572](https://discuss.elastic.co/u/mussa572)\
**Post date:** [December 5, 2017, 11:03am UTC](https://discuss.elastic.co/t/ingest-specific-json-fields-to-elastichsearch/110324/1 "2017-12-05T11:03:15Z")

</div>

Hi I am ingesting following Json data to elasticseach through Logstash . There are around 100 different fields in that document. I am only interested in sending 4 fields ie **linux.domain, linux.environment\_id, linux.hostname and linux.id .**  
Is there a better to include only 4 fields I am interested in sending to elasticserch instead of using remove\_field option and manually add all 100 fields in the config.

grok {  
remove\_field =\> ["linux.architecture","linux.architecture\_id","linux.architecture\_name"]-----\> do not want to remove manually

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/a/5/a56bc51e838191f8bda51a27144a84e18dc70b71.png)  
My logstash config :

```
input {
 beats {
        port => "5044"
        type => ["doc"]
       }
}

filter {

grok {

match => {"message" => "^{?\n?.*?(?<logged_json>{.*)" }

}

json

{
      source => "logged_json"
      target => "linux"
# remove_field => "parameter"
}

}
output {
if [type] == "doc" {

   elasticsearch {
        hosts => ["10.138.7.51:9200"]
        index => "testing-%{+YYYY-MM-dd}"

}
}
else if [type] != "doc" {
  elasticsearch {
        hosts => ["10.138.7.51:9200"]
        index => "tester-%{+YYYY-MM-dd}"

}

}
```

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [December 5, 2017, 11:19am UTC](https://discuss.elastic.co/t/ingest-specific-json-fields-to-elastichsearch/110324/2 "2017-12-05T11:19:47Z")

</div>

Use a mutate filter to rename (i.e. move) the wanted fields to the top level of the events, then use a mutate filter to remove the `linux` field and all of its subfields.

Note the syntax Logstash requires for the nested fields you want to rename: [https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#logstash-config-field-references](https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#logstash-config-field-references)

---

<div class="post-metadata">

**Author:** ![mussa572](https://avatars.discourse-cdn.com/v4/letter/m/a698b9/32.png) [@mussa572](https://discuss.elastic.co/u/mussa572)\
**Post date:** [December 5, 2017, 4:47pm UTC](https://discuss.elastic.co/t/ingest-specific-json-fields-to-elastichsearch/110324/3 "2017-12-05T16:47:22Z")

</div>

Thanks Magnus ,

Worked as per your suggestion .

---

<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:** [January 2, 2018, 4:47pm UTC](https://discuss.elastic.co/t/ingest-specific-json-fields-to-elastichsearch/110324/4 "2018-01-02T16:47:27Z")

</div>

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