# How to write only specific fields to elasticsearch from logstash

**URL:** https://discuss.elastic.co/t/how-to-write-only-specific-fields-to-elasticsearch-from-logstash/44176
**Category:** Logstash
**Created:** [March 11, 2016, 3:54pm UTC](https://discuss.elastic.co/t/how-to-write-only-specific-fields-to-elasticsearch-from-logstash/44176 "2016-03-11T15:54:10Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![MikeM](https://avatars.discourse-cdn.com/v4/letter/m/41988e/32.png) [@MikeM](https://discuss.elastic.co/u/MikeM)
#### Post date: [March 11, 2016, 3:54pm UTC](https://discuss.elastic.co/t/how-to-write-only-specific-fields-to-elasticsearch-from-logstash/44176/1 "2016-03-11T15:54:10Z")

</div>

I want to output an event to elasticsearch, but I really only want to have 4 - 6 fields in the index, but the event is coming in with 130 fields. I know that I can use the remove\_field array in a mutate or other filter, but that means that I would have to list out 120+ field names in the logstash config.

Is there an easy way to specify only specific fields to write to ES? I was thinking about the clone filter, but it doesn't seem to let you clone only certain events of a field.

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [March 12, 2016, 8:41am UTC](https://discuss.elastic.co/t/how-to-write-only-specific-fields-to-elasticsearch-from-logstash/44176/2 "2016-03-12T08:41:19Z")

</div>

What sort of file is it? CSV, other?

---

<div class="post-metadata">

### Author: ![MikeM](https://avatars.discourse-cdn.com/v4/letter/m/41988e/32.png) [@MikeM](https://discuss.elastic.co/u/MikeM)
#### Post date: [March 12, 2016, 10:34pm UTC](https://discuss.elastic.co/t/how-to-write-only-specific-fields-to-elasticsearch-from-logstash/44176/3 "2016-03-12T22:34:13Z")

</div>

Not a file. It's a log being sent to logstash on a TCP port.

---

<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: [March 14, 2016, 6:46am UTC](https://discuss.elastic.co/t/how-to-write-only-specific-fields-to-elasticsearch-from-logstash/44176/4 "2016-03-14T06:46:44Z")

</div>

The [prune filter](https://www.elastic.co/guide/en/logstash/current/plugins-filters-prune.html) allows you to remove all fields except the list of 4–6 fields that you want to keep.

---

<div class="post-metadata">

### Author: ![MikeM](https://avatars.discourse-cdn.com/v4/letter/m/41988e/32.png) [@MikeM](https://discuss.elastic.co/u/MikeM)
#### Post date: [March 17, 2016, 8:00pm UTC](https://discuss.elastic.co/t/how-to-write-only-specific-fields-to-elasticsearch-from-logstash/44176/5 "2016-03-17T20:00:50Z")

</div>

awesome! This looks like the filter I was looking for. I'll test it. Thanks for the heads up!

---

<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: [July 6, 2017, 5:06am UTC](https://discuss.elastic.co/t/how-to-write-only-specific-fields-to-elasticsearch-from-logstash/44176/6 "2017-07-06T05:06:36Z")

</div>


