How to read UTF-16LE encoded CSV files using file input plugin

Hi Team,

I wanted to read the CSV files which are encoded in UTF-16LE or UTF-8 in logstash. Could you please help me how i can achieve it. I have tried like this which is failing.

input {
  file {
     id => "nasapmena-orders-input"
     path => "/data/Elastic/logstash/Orders_20241113142312.csv"
     mode => "read"
     codec => plain { charset=>"UTF-8" }
        }
}

Thanks for reaching out, @venkatkumar229. Would something like this work for you:

input {
  file {
    path => "/data/Elastic/logstash/Orders_20241113142312.csv"
    start_position => "beginning"
    sincedb_path => "/dev/null" 
    codec => plain {
      charset => "UTF-16LE"
    }
  }
}

This example includes start_position => "beginning" to ensure that that logstash always starts reading at the beginning of the file and sincedb_path => "/dev/null" for testing purposes so Logstash will ignore what files have been processed in previous runs.

1 Like