# Elasticsearch Output Plugin - Batching, How?

**URL:** <https://discuss.elastic.co/t/elasticsearch-output-plugin-batching-how/268469>\
**Category:** Logstash\
**Created:** [March 26, 2021, 10:40am UTC](https://discuss.elastic.co/t/elasticsearch-output-plugin-batching-how/268469 "2021-03-26T10:40:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Liam\_B](https://avatars.discourse-cdn.com/v4/letter/l/ad7895/32.png) [@Liam\_B](https://discuss.elastic.co/u/Liam_B)\
**Post date:** [March 26, 2021, 10:40am UTC](https://discuss.elastic.co/t/elasticsearch-output-plugin-batching-how/268469/1 "2021-03-26T10:40:40Z")

</div>

In the Logstash elastic search output documentation it mentions...

Batch Sizes: This plugin attempts to send batches of events to the [Elasticsearch Bulk API]

I can't find any information on how the batches are buffered, is it time based or document count based, when is it flushed etc?

I have taken a quick look at [GitHub - logstash-plugins/logstash-output-elasticsearch](https://github.com/logstash-plugins/logstash-output-elasticsearch) and I can't see any code mentioning batches only comments.

---

<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:** [March 26, 2021, 4:51pm UTC](https://discuss.elastic.co/t/elasticsearch-output-plugin-batching-how/268469/2 "2021-03-26T16:51:51Z")

</div>

My understanding is that when a batch of events exits the pipeline it will get passed to [multi\_receive](https://github.com/logstash-plugins/logstash-output-elasticsearch/blob/9401759a165f51e4b10dd195b1394760dc70dd92/lib/logstash/outputs/elasticsearch.rb#L299), which immediately indexes them. It calls the [mixin](https://github.com/logstash-plugins/logstash-output-elasticsearch/blob/9401759a165f51e4b10dd195b1394760dc70dd92/lib/logstash/plugin_mixins/elasticsearch/common.rb#L150), which calls submit, which calls safe\_bulk, which call the [bulk](https://github.com/logstash-plugins/logstash-output-elasticsearch/blob/9401759a165f51e4b10dd195b1394760dc70dd92/lib/logstash/outputs/elasticsearch/http_client.rb#L93) method of the client. That is the code which does size based batching, in case a single batch from the pipeline is larger than 20 MB.

---

<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:** [April 23, 2021, 4:52pm UTC](https://discuss.elastic.co/t/elasticsearch-output-plugin-batching-how/268469/3 "2021-04-23T16:52:49Z")

</div>

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