# Export from elasticsearch to csv problem. Where I am wrong?

**URL:** <https://discuss.elastic.co/t/export-from-elasticsearch-to-csv-problem-where-i-am-wrong/65558>\
**Category:** Logstash\
**Created:** [November 9, 2016, 9:18pm UTC](https://discuss.elastic.co/t/export-from-elasticsearch-to-csv-problem-where-i-am-wrong/65558 "2016-11-09T21:18:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Swina\_Allen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/swina_allen/32/6598_2.png) [@Swina\_Allen](https://discuss.elastic.co/u/Swina_Allen)\
**Post date:** [November 9, 2016, 9:18pm UTC](https://discuss.elastic.co/t/export-from-elasticsearch-to-csv-problem-where-i-am-wrong/65558/1 "2016-11-09T21:18:41Z")

</div>

Hi have the following logstash config file:  
input {  
elasticsearch {  
hosts =\> ["localhost"]  
index =\> "myindex"  
type =\> "mytype"  
query =\> '{"query" : { "match\_all" : {} }}'  
}  
}  
output {  
csv {  
fields =\> [my\_fields\_array]  
path =\> "export.csv  
csv\_options =\> {"col\_sep" =\> "\t" "row\_sep" =\> "\r\n"}  
}  
}

Opening export.csv i don't get any mapped data fields but only a list of something like:  
2016-11-02T07:41:15.917Z %{host} %{message}2016-11-02T07:41:16.708Z %{host}...

Any idea about this?  
Thank you

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [November 14, 2016, 6:42am UTC](https://discuss.elastic.co/t/export-from-elasticsearch-to-csv-problem-where-i-am-wrong/65558/2 "2016-11-14T06:42:04Z")

</div>

Which version of Logstash? I can't reproduce this with 2.4.0:

```nohighlight
$ cat in 
{"a": 1, "b": 2, "c": 3}
$ cat test.config 
input { stdin { codec => json } }
output {
  csv {
    fields => ["a", "b"]
    path => "out"
  }
}
$ /opt/logstash/bin/logstash -f test.config < in
Settings: Default pipeline workers: 8
Pipeline main started
Pipeline main has been shutdown
stopping pipeline {:id=>"main"}
$ cat out 
1,2

```

---

<div class="post-metadata">

**Author:** ![nikolaosbukas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nikolaosbukas/32/13160_2.png) [@nikolaosbukas](https://discuss.elastic.co/u/nikolaosbukas)\
**Post date:** [November 15, 2016, 2:04am UTC](https://discuss.elastic.co/t/export-from-elasticsearch-to-csv-problem-where-i-am-wrong/65558/3 "2016-11-15T02:04:37Z")

</div>

I am experiencing the same problem with Logstash 5.0. I tried it out on Logstash 2.1.0 and it works correctly.

My config file

```
input {
stdin {}
}
filter {
    grok {
        break_on_match => true
        match => [
            "message", "%{DATA:key} %{GREEDYDATA:data}"
        ]
    }
}
output {
stdout {codec => dots}

   stdout {codec => rubydebug}
stdout {}

csv {
    fields => ["key", "data"]
    path => "/tmp/output.csv"
}}

```

My input to stdin:  
`A B`

Output CSV in Logstash 2.1.0  
`A,B`

Output CSV in Logstash 5.0  
`2016-11-15T02:01:28.047Z SEA-1201050405 A B`

---

<div class="post-metadata">

**Author:** ![Swina\_Allen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/swina_allen/32/6598_2.png) [@Swina\_Allen](https://discuss.elastic.co/u/Swina_Allen)\
**Post date:** [November 15, 2016, 7:18am UTC](https://discuss.elastic.co/t/export-from-elasticsearch-to-csv-problem-where-i-am-wrong/65558/4 "2016-11-15T07:18:44Z")

</div>

logstash 5.0.0

---

<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:** [December 13, 2016, 7:19am UTC](https://discuss.elastic.co/t/export-from-elasticsearch-to-csv-problem-where-i-am-wrong/65558/5 "2016-12-13T07:19:12Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
