Add header row to CSV output


#1

Hi,

I need to create date-specific CSV files with logstash, but can't see how to write a header row. Is this even possible?

Thanks,
Andrew


(Magnus Bäck) #2

I guess

csv {
  ...
  csv_options => {
    "headers" => true
  }
}

should work but after reading the code I suspect it won't actually work since Logstash never supplies the CSV library with the names of the fields.


#3

Magnus,

You are correct – that option does not cause the headers to be written. Does this mean it’s not possible? Feature request?

Thanks,
Andrew


(Magnus Bäck) #4

Yeah, right now it isn't possible. Seems like a reasonable feature request though. Feel free to file a GitHub issue: https://github.com/logstash-plugins/logstash-output-csv/issues/new


(Henri) #5

Now you need to add

csv_options => {
        "write_headers" => true
        "headers" =>["line1", "line2", "line3","line4","line5"]
}

But the bad thing is that it add header for each line, not only on the first one....


(system) #6