Output csv with header(columns)
Is your feature request related to a problem? Please describe.
I want fluentd to write a csv file with header like below. (The header is written in only head of a file, of course.)
e.g.
time,host,req_id,user
2013/02/28 12:00:00,192.168.0.1,111,-
2013/02/28 13:00:00,192.168.0.1,111,-
In my project, I must make a service outputs csv logs with headers like below example. However, fluentd emit a record one by one that not to consider if it is header. Is there future considering about handling this?
Describe the solution you'd like
No specific cool solution now. And I don't know this usage suites fluentd concepts. Anyway, I have just written an ad hoc plugin extending out_file plugin. I'll explain it next item.
Well, I move on talk about practical implementation. Would be nice to have some kind of "isHeader" if user need header. I think it is OK with modifying out_file or making a new plugin handling it. I hope we discuss that.
Describe alternatives you've considered
Here is the code snippet. I understand it is not cool.
def write_without_compression(path, chunk)
File.open(path, "ab", @file_perm) do |f|
# Add below code block.
if f.stat.size == 0
# I cannot fetch "fields" from fluentd, so I just put it directly.
# This is because only formatter plugins contain "fields" information as object, I think.
f.write("time,host,req_id,user")
f.write("\n")
end
chunk.write_to(f)
end
end
This barely completes my demand.
Additional context N/A
I have released a plugin handling a file header. Here is the link: https://github.com/pomcho555/fluent-plugin-file-with-header
So, this can be closed if fluentd doesn't consider this support anymore.