# Include field names before docs (data)

**URL:** <https://discuss.elastic.co/t/include-field-names-before-docs-data/134663>\
**Category:** Logstash\
**Created:** [June 5, 2018, 3:56pm UTC](https://discuss.elastic.co/t/include-field-names-before-docs-data/134663 "2018-06-05T15:56:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexus](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexus/32/12696_2.png) [@alexus](https://discuss.elastic.co/u/alexus)\
**Post date:** [June 5, 2018, 3:56pm UTC](https://discuss.elastic.co/t/include-field-names-before-docs-data/134663/1 "2018-06-05T15:56:57Z")

</div>

In order to export docs from Elasticsearch, I'm trying to utilize [Csv output plugin | Logstash Reference](https://www.elastic.co/guide/en/logstash/current/plugins-outputs-csv.html) for that, however I stumble upon small issue..

Is there a way to add field names as first line (before data)?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [June 5, 2018, 4:16pm UTC](https://discuss.elastic.co/t/include-field-names-before-docs-data/134663/2 "2018-06-05T16:16:46Z")

</div>

Not that I can see. The code does this.

```
csv_values = @fields.map {|name| get_value(name, event)}
csv_values.to_csv(@csv_options)

```

map returns an array of field values, so by the time to\_csv is called the association with the names has been lost.

It would be possible to modify the output to have an option to add a header row and this has been [requested](https://github.com/logstash-plugins/logstash-output-csv/issues/8), but no such option currently exists.

---

<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 3, 2018, 4:16pm UTC](https://discuss.elastic.co/t/include-field-names-before-docs-data/134663/3 "2018-07-03T16:16:53Z")

</div>

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