# Logstash Output CSV Plugin produces no content in the output file

**URL:** <https://discuss.elastic.co/t/logstash-output-csv-plugin-produces-no-content-in-the-output-file/29078>\
**Category:** Logstash\
**Created:** [September 10, 2015, 10:33pm UTC](https://discuss.elastic.co/t/logstash-output-csv-plugin-produces-no-content-in-the-output-file/29078 "2015-09-10T22:33:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bill.T](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Bill.T](https://discuss.elastic.co/u/Bill.T)\
**Post date:** [September 10, 2015, 10:33pm UTC](https://discuss.elastic.co/t/logstash-output-csv-plugin-produces-no-content-in-the-output-file/29078/1 "2015-09-10T22:33:55Z")

</div>

I am trying to write an output CSV file that contains two of the four columns from an input CSV file. It appears that the input file is correctly parsed and mapped. The output file is created but nothing gets written to it. It is empty.

Here is my config file:

input {  
file { path =\> "/opt/logstash/testdata/testinput1.txt"  
sincedb\_path =\> "/opt/logstash/perl-scripts/sincedb3"  
start\_position =\> "beginning"  
}  
}

filter {  
csv {  
columns =\> ["patientid", "name", "health", "concerns"]  
separator =\> ","  
}  
}

output {  
stdout { codec =\> rubydebug }

# file { path =\> "/opt/logstash/testdata/testoutput1.txt" }

csv {  
path =\> "/opt/logstash/testdata/nameout.csv"  
fields =\> ["patientid", "name"]  
csv\_options =\> {"col\_sep" =\> "," "row\_sep" =\> "\r\n"}  
}  
}

The STDOUT output shows:  
{  
"message" =\> [  
[0] "12345, Joe Blogs, great health, no worries"  
],  
"@version" =\> "1",  
"@timestamp" =\> "2015-09-10T22:24:14.068Z",  
"host" =\> "sem-catalog",  
"path" =\> "/opt/logstash/testdata/testinput1.txt",  
"patientid" =\> "12345",  
"name" =\> " Joe Blogs",  
"health" =\> " great health",  
"concerns" =\> " no worries"  
}  
Opening file {:path=\>"/opt/logstash/testdata/nameout.csv", :level=\>:info}  
{  
"message" =\> [  
[0] "12346, Karen Feeding, good health, some worries"  
],  
"@version" =\> "1",  
"@timestamp" =\> "2015-09-10T22:24:14.070Z",  
"host" =\> "sem-catalog",  
"path" =\> "/opt/logstash/testdata/testinput1.txt",  
"patientid" =\> "12346",  
"name" =\> " Karen Feeding",  
"health" =\> " good health",  
"concerns" =\> " some worries"  
}  
. . . .

Here are a few sample records from the input file. . . .

12341, Robin Banks, great health, no worries  
12342, Willy Show, good health, some worries  
12343, Lotta Troubles, great health, no worries  
12345, Izzy Breathin, good health, some worries

The output should look like:  
12341, Robin Banks  
12342, Willy Show  
12343, Lotta Troubles  
12345, Izzy Breathin

UPDATE: The output was getting cached. Upon hitting CTRL-C to terminate logstash, the output file gets written as expected. Also, the default 'plain' codec works best for me. The new config file is:

input {  
file { path =\> "/opt/logstash/testdata/testinput1.txt"  
sincedb\_path =\> "/opt/logstash/perl-scripts/sincedb3"  
start\_position =\> "beginning"  
}  
}

filter {  
csv {  
columns =\> ["patientid", "name", "health", "concerns"]  
separator =\> ","  
}  
}

output {  
stdout { codec =\> rubydebug }  
csv {  
path =\> "/opt/logstash/testdata/nameout.csv"  
fields =\> ["patientid", "name"]  
}  
}

PROBLEM SOLVED

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 5:29am UTC](https://discuss.elastic.co/t/logstash-output-csv-plugin-produces-no-content-in-the-output-file/29078/2 "2017-07-06T05:29:28Z")

</div>


