# How does logstash generate '\_id' when the outputting to elastic search?

**URL:** <https://discuss.elastic.co/t/how-does-logstash-generate--id-when-the-outputting-to-elastic-search/53722>\
**Category:** Logstash\
**Created:** [June 23, 2016, 2:02am UTC](https://discuss.elastic.co/t/how-does-logstash-generate--id-when-the-outputting-to-elastic-search/53722 "2016-06-23T02:02:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthew\_Laue](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@Matthew\_Laue](https://discuss.elastic.co/u/Matthew_Laue)\
**Post date:** [June 23, 2016, 2:02am UTC](https://discuss.elastic.co/t/how-does-logstash-generate--id-when-the-outputting-to-elastic-search/53722/1 "2016-06-23T02:02:59Z")

</div>

The elasticsearch \_id parameter is set to some hash value. e.g.

"\_id": "AVVpVdoIEU8QqcRWkA9P",

How is this calculated? And where?

```
matt@elk:~$ cat /etc/logstash/conf.d/apache.conf 
input {
    file {
        path => '/var/log/apache2/access.log'
    }
}
    
filter {
    grok {
        match => { "message" => "%{COMBINEDAPACHELOG}" }
    }
}
    
output {
    elasticsearch { 
    }
}
```

---

<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:** [June 23, 2016, 4:49am UTC](https://discuss.elastic.co/t/how-does-logstash-generate--id-when-the-outputting-to-elastic-search/53722/2 "2016-06-23T04:49:30Z")

</div>

ES will [automatically create an ID](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html#_automatic_id_generation) in case you don't specify any.

In this case, the Logstash `elasticsearch` output plugin will send the events to the `_bulk` endpoint without any `_id` and hence ES will create IDs for your newly indexed documents automatically. If you want to provide your own IDs from within Logstash, you can do so by specifying the `document_id` setting:

```
output {
    elasticsearch { 
        document_id => "%{some_id_field}"
    }
}
```

---

<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, 4:51am UTC](https://discuss.elastic.co/t/how-does-logstash-generate--id-when-the-outputting-to-elastic-search/53722/3 "2017-07-06T04:51:02Z")

</div>


