# Export to CSV with all fields - Logstash 7.0.1

**URL:** <https://discuss.elastic.co/t/export-to-csv-with-all-fields-logstash-7-0-1/187420>\
**Category:** Logstash\
**Created:** [June 25, 2019, 7:18pm UTC](https://discuss.elastic.co/t/export-to-csv-with-all-fields-logstash-7-0-1/187420 "2019-06-25T19:18:38Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [June 25, 2019, 8:00pm UTC](https://discuss.elastic.co/t/export-to-csv-with-all-fields-logstash-7-0-1/187420/2 "2019-06-25T20:00:57Z")

</div>

> [@etsai7](#):
>
> Is there a way to configure the output to csv file to include all fields in the index by default so that each one does not have to be manually typed out?

Fields is a required option. It does not support %{[fieldname]} references but it will support environment variable substitution. However, it will treat a substituted environment variable as a string, even if it looks like an array. So the answer is no.

Except you can have logstash tell you what to type, which reduces it to copy and paste. Run a line of your data through this...

```
filter {
    ruby {
        code => '
            csvFields = []
            event.to_hash.each { |k, v|
                csvFields << k
            }
            event.set("[csvFields]", csvFields.to_s)
        '
    }
}
output { stdout { codec => plain { format => "%{csvFields}
" } } }

```

---

_[View the full topic](https://discuss.elastic.co/t/export-to-csv-with-all-fields-logstash-7-0-1/187420)._
