# File output with Header like CSV

**URL:** <https://discuss.elastic.co/t/file-output-with-header-like-csv/107564>\
**Category:** Logstash\
**Created:** [November 14, 2017, 3:19pm UTC](https://discuss.elastic.co/t/file-output-with-header-like-csv/107564 "2017-11-14T15:19:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![krishna\_chaitanya](https://avatars.discourse-cdn.com/v4/letter/k/b5a626/32.png) [@krishna\_chaitanya](https://discuss.elastic.co/u/krishna_chaitanya)\
**Post date:** [November 14, 2017, 3:19pm UTC](https://discuss.elastic.co/t/file-output-with-header-like-csv/107564/1 "2017-11-14T15:19:38Z")

</div>

I am using logstash 5.4 and trying to create a CSV file from the events processed.  
With csv output plugin, I got into same issue as this one:

[https://discuss.elastic.co/t/csv-output-failing-in-logstash-5-1-2/73751](https://discuss.elastic.co/t/csv-output-failing-in-logstash-5-1-2/73751)

The output is something like this, as mentioned in the post:  
sequence of strings - %{host} %{message}%{host} %{message}%{host} %{message}

Based on solution suggested in that post, I am using file output plugin with config like this:

```
file {
    codec => line { format => %{field1},"%{field2}"}
    path => "/path/to/data_export.csv"
}

```

This solves my problem a bit.  
What I also need is the header for the csv file as well. How can I have header for the file with file output plugin ?

---

<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:** [December 12, 2017, 3:19pm UTC](https://discuss.elastic.co/t/file-output-with-header-like-csv/107564/2 "2017-12-12T15:19:42Z")

</div>

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