File output with Header like CSV

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:

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 ?

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