# Logstash CSV output giving wrong format

**URL:** https://discuss.elastic.co/t/logstash-csv-output-giving-wrong-format/74413
**Category:** Logstash
**Created:** [February 8, 2017, 5:02pm UTC](https://discuss.elastic.co/t/logstash-csv-output-giving-wrong-format/74413 "2017-02-08T17:02:33Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Mielzus](https://avatars.discourse-cdn.com/v4/letter/m/278dde/32.png) [@Mielzus](https://discuss.elastic.co/u/Mielzus)
#### Post date: [February 8, 2017, 5:02pm UTC](https://discuss.elastic.co/t/logstash-csv-output-giving-wrong-format/74413/1 "2017-02-08T17:02:33Z")

</div>

I am using Logstash to parse a file containing single line JSON data and output it in a CSV formatted file. Instead of outputting the data as nice separated values it is giving me single line data using timestamp, host, and message fields. Has anyone else encountered this issue and know how to fix it?

## Output

Current output

```auto
2017-02-08T16:48:45.907Z %{host} %{message}2017-02-08T16:48:45.907Z %{host} %{message}
2017-02-08T16:48:45.907Z %{host} %{message}2017-02-08T16:48:45.907Z %{host} %{message}
2017-02-08T16:48:45.907Z %{host} %{message}2017-02-08T16:48:45.907Z %{host} %{message}

```

Desired output

```auto
timestamp, id, name
timestamp, id, name
timestamp, id, name

```

Config file:

```auto
input {
	file {
		path => "input path"
		sincedb_path => "C:\Logstash\.sincedb*"
		start_position => "beginning"
        codec => "json"
		type => "type"
	}
}

filter {
    mutate {
        add_field => {"eventName" => "%{[event][eventName]}"}
        add_field => {"uniqueDeviceID" => "%{[event][deviceSegment][uniqueDeviceID]}"}
    }
    prune {
        whitelist_names => ["eventName", "uniqueDeviceID", "@timestamp"]
    }
}

output {
    stdout {codec => rubydebug}
    csv {
        fields => ["uniqueDeviceID", "eventName", "@timestamp"]
        path => "output path"
    }
}

```

---

<div class="post-metadata">

### Author: ![val](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/val/32/138203_2.png) [@val](https://discuss.elastic.co/u/val)
#### Post date: [February 10, 2017, 5:15am UTC](https://discuss.elastic.co/t/logstash-csv-output-giving-wrong-format/74413/2 "2017-02-10T05:15:17Z")

</div>

The issue might come from the fact that you're using Logstash 5.x, which still has an [open issue](https://github.com/logstash-plugins/logstash-output-csv/issues/10) that prevents the `csv` output from properly consuming events. If that's the case, you may downgrade to Logstash 2.x until this gets resolved.

---

<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: [March 10, 2017, 5:15am UTC](https://discuss.elastic.co/t/logstash-csv-output-giving-wrong-format/74413/3 "2017-03-10T05:15:16Z")

</div>

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