# Logstash csv output filter

**URL:** <https://discuss.elastic.co/t/logstash-csv-output-filter/150711>\
**Category:** Logstash\
**Created:** [October 2, 2018, 1:12pm UTC](https://discuss.elastic.co/t/logstash-csv-output-filter/150711 "2018-10-02T13:12:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pastechecker](https://avatars.discourse-cdn.com/v4/letter/p/0ea827/32.png) [@pastechecker](https://discuss.elastic.co/u/pastechecker)\
**Post date:** [October 2, 2018, 1:12pm UTC](https://discuss.elastic.co/t/logstash-csv-output-filter/150711/1 "2018-10-02T13:12:15Z")

</div>

Hello.  
I am querying my ES using Logstash.  
I want to output the id of the record from ES into my csv file.

> "\_index": "data",  
> "\_type": "default",  
> **"\_id": "vANfNGYB9XD0VZRJUFfy",**  
> "\_version": 1,  
> "\_score": null,  
> "\_source": {  
> ....

> output { csv {  
> fields =\> ["field1", "field2", "field3", "\_id"]  
> path =\> "/tmp/export.%{+YYYY-MM-dd-hh}.csv"  
> }  
> }

but the \_id is never logged to my csv. All other fields are there as expected, but the special metadata \_id field is not there.  
How can I get it there? I do not want to edit 60+ pipelines I have just to clone one field into another.

---

<div class="post-metadata">

**Author:** ![pastechecker](https://avatars.discourse-cdn.com/v4/letter/p/0ea827/32.png) [@pastechecker](https://discuss.elastic.co/u/pastechecker)\
**Post date:** [October 2, 2018, 2:18pm UTC](https://discuss.elastic.co/t/logstash-csv-output-filter/150711/2 "2018-10-02T14:18:04Z")

</div>

Found solution:

When we query ES we have to enable docinfo =\> true. By default it is false.

```auto
input {
 elasticsearch {
  hosts => [your hosts]
  index => "ti"
  query => '{your query}'
  size => 1000
  scroll => "1s"
  docinfo => true
  schedule => "14 * * * *"
 }
}

```

We can than access the metadata with syntax:  
"[@metadata][\_id]",

---

<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:** [October 30, 2018, 2:18pm UTC](https://discuss.elastic.co/t/logstash-csv-output-filter/150711/3 "2018-10-30T14:18:05Z")

</div>

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