Hi @Badger , thanks for replying back. I tried again multiple times, looks like i am missing something.
Please checkout this my complete file. Please suggest whats wrong here, i am not a big expert of ruby.
Are you saying i need 2 outputs one on csv and other stdout, i am not clear on it
input{
file {
path => "......./cumsum.csv"
sincedb_path => "......../cumsum.txt"
start_position => "beginning"
type => "csv"
}
}
filter {
csv {
autodetect_column_names => true
remove_field => [ "message" ]
}
ruby {
code => '
csvFields =
event.to_hash.each { |k, v|
csvFields << k
}
event.set("[csvFields]", csvFields.to_s)
'
}
ruby {
code => 'event.set(event.get("Type"), event.get("Count"))'
}
}
output {
file {
path => ".........\output.csv"
codec => plain { format => "%{csvFields}" }
}
}
I am getting this response in the output.csv file
`
["A001", "type", "@timestamp", "5", "P0", "@version", "path", "host"]["A001", "type", "@timestamp", "5", "P0", "@version", "path", "host"]["A001", "type", "@timestamp", "5", "P0", "@version", "path", "host"]["A001", "type", "@timestamp", "5", "P0", "@version", "path", "host"]
`