# Add header row to csv output file

**URL:** <https://discuss.elastic.co/t/add-header-row-to-csv-output-file/244010>\
**Category:** Logstash\
**Created:** [August 6, 2020, 11:28am UTC](https://discuss.elastic.co/t/add-header-row-to-csv-output-file/244010 "2020-08-06T11:28:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![akhilsharma.in](https://avatars.discourse-cdn.com/v4/letter/a/6f9a4e/32.png) [@akhilsharma.in](https://discuss.elastic.co/u/akhilsharma.in)\
**Post date:** [August 6, 2020, 11:28am UTC](https://discuss.elastic.co/t/add-header-row-to-csv-output-file/244010/1 "2020-08-06T11:28:56Z")

</div>

Using csv output plugin to store JSON field data. But there are no column names; wondering how to give names to columns or how to add header row.

---

<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:** [August 6, 2020, 1:47pm UTC](https://discuss.elastic.co/t/add-header-row-to-csv-output-file/244010/2 "2020-08-06T13:47:33Z")

</div>

You can use the csv\_options option on the csv output to tell it to add a header row, but since every row is written independently each one will have a header. That is, every other row of the output will be a header.

You may be able to write the header row to the output file before running logstash.

---

<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:** [September 3, 2020, 1:47pm UTC](https://discuss.elastic.co/t/add-header-row-to-csv-output-file/244010/3 "2020-09-03T13:47:36Z")

</div>

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