Nordes
Nordes

Reputation: 2521

Not able to create csv output from LogStash

Maybe it is me, but how come that when I use the CSV Output from LogStash it does not output in a csv format? I am using nothing special (as seen in the configuration). Can someone tell me what I am doing wrong?

input
{
    stdin {
        type => "stdin-type"
    }
}

filter
{
    mutate { add_field => { "test" => "testme" } }
    mutate { add_field => { "[@metadata][test]" => "Hello" } }
    mutate { add_field => { "[@metadata][test2]" => "world" } }
}

output {
    # .\bin\logstash-plugin.bat install logstash-output-csv
    csv {
        fields => ["test", "[@metadata][test]"]
        path => "./TestLogs.csv"
    }

    stdout { codec => rubydebug { metadata => true } }
}

It actually create an output. If I type something (Ex.: test me) in the console (stdin) it creates the file and all. But the CSV file contains the following:

2016-11-25T11:49:40.338Z MyPcName test me

And I am expecting the following:

testme,Hello

Note: I am using LogStash 5 (latest version at the moment).

Upvotes: 0

Views: 727

Answers (1)

Yee
Yee

Reputation: 32

This is a Logstash 5.x issue. For now, I'm using the script below:

output {
   file {
      path => "/app/logstash/test.csv"
      message_pattern => (grok pattern)
     }

Upvotes: 1

Related Questions