13

I have tab separated data which I want to input into logstash. Here is my configuration file:

input {
    file {
        path => "/*.csv"
        type => "testSet"
        start_position => "beginning"
    }
}

filter {
    csv {
        separator => "\t"
    }
}

output {
    stdout {
        codec => rubydebug
    }
}

It simply looks for all .csv files and separates them using tabs. For an input like this:

col1    col2
data1    data2

logstash output is (for the two rows):

column1 => "col1\tcol2"
column1 => "data1\tdata2"

Obviously it is not correctly parsing it. I saw that this issue was brought up a while ago here but there was no solution. Does anyone know if this problem has been resolved or maybe there's another way to do it? Thanks!

Srini
  • 1,626
  • 2
  • 15
  • 25
Noah Santacruz
  • 460
  • 1
  • 3
  • 18

2 Answers2

35

Instead of using "\t" as the seperator, input an actual tab. like this:

filter {
   csv {
    separator => "  "
   }
}
Roman
  • 2,108
  • 1
  • 18
  • 20
0

https://www.elastic.co/guide/en/logstash/6.2/plugins-filters-csv.html#plugins-filters-csv-separator

Define the column separator value. If this is not specified, the default is a comma ,. If you want to define a tabulation as a separator, you need to set the value to the actual tab character and not \t.

Lynn Han
  • 443
  • 6
  • 8