# Logstash http output plugin customize building json array for batching

**URL:** https://discuss.elastic.co/t/logstash-http-output-plugin-customize-building-json-array-for-batching/275535
**Category:** Logstash
**Created:** [June 10, 2021, 8:24am UTC](https://discuss.elastic.co/t/logstash-http-output-plugin-customize-building-json-array-for-batching/275535 "2021-06-10T08:24:46Z")
**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 10, 2021, 4:29pm UTC](https://discuss.elastic.co/t/logstash-http-output-plugin-customize-building-json-array-for-batching/275535/2 "2021-06-10T16:29:31Z")

</div>

> [@RahulGS](#):
>
> How do i go about combining batch of messages using my own json format ?

That is not simple. outputs sometimes have a receive method that consumes a single event, and sometimes have a multi\_receive method that consumes an array of events (a batch). The multi\_receive method typically iterates over the array and processes the events one at a time. The http output is unusual in that it can process the entire array in one shot. However, it provides no flexibility on the request format that it sends over http.

That means you will have to do some work in the filter section, and the filter section does not see a batch, it sees individual events.

If you are OK with sending one event per request

```auto
{ records : [{json1}] }
{ records : [{json2}] }
{ records : [{json3}] }

```

etc., then modifying the format is not very hard.

Otherwise you are going to have to aggregate the events to create a batch. That can be done. There is an example of combining events with a limit on size [here](https://discuss.elastic.co/t/aggregate-filter-push-on-event-size-limit/180875/2). You could change that to add a set number of events to an array, effectively re-creating the batch.

Which approach do you prefer?

---

_[View the full topic](https://discuss.elastic.co/t/logstash-http-output-plugin-customize-building-json-array-for-batching/275535)._
