# How to create multiple events in logstash to push multiple request in elasticsearch

**URL:** <https://discuss.elastic.co/t/how-to-create-multiple-events-in-logstash-to-push-multiple-request-in-elasticsearch/103732>\
**Category:** Logstash\
**Created:** [October 12, 2017, 1:22pm UTC](https://discuss.elastic.co/t/how-to-create-multiple-events-in-logstash-to-push-multiple-request-in-elasticsearch/103732 "2017-10-12T13:22:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajit](https://avatars.discourse-cdn.com/v4/letter/a/a3d4f5/32.png) [@ajit](https://discuss.elastic.co/u/ajit)\
**Post date:** [October 12, 2017, 1:22pm UTC](https://discuss.elastic.co/t/how-to-create-multiple-events-in-logstash-to-push-multiple-request-in-elasticsearch/103732/1 "2017-10-12T13:22:32Z")

</div>

I have logstash configuration. I want to take data from one event manipulate the data and create multiple events and push that events to elasticsearch.  
e.g.  
{  
"activity" : "meeting",  
"clientName" : "ABC/XYZ/LMN"  
"Duration" : 60  
}

above example shows my original event message.  
But I want to divide that message into three json objects (events) like below:  
{  
"activity" : "meeting",  
"clientName" : "ABC"  
"Duration" : 20  
},  
{  
"activity" : "meeting",  
"clientName" : "XYZ"  
"Duration" : 20  
},  
{  
"activity" : "meeting",  
"clientName" : "LMN"  
"Duration" : 20  
}

---

<div class="post-metadata">

**Author:** ![paz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paz/32/28003_2.png) [@paz](https://discuss.elastic.co/u/paz)\
**Post date:** [October 12, 2017, 1:36pm UTC](https://discuss.elastic.co/t/how-to-create-multiple-events-in-logstash-to-push-multiple-request-in-elasticsearch/103732/2 "2017-10-12T13:36:30Z")

</div>

A decent solution would be the [split filter](https://www.elastic.co/guide/en/logstash/5.6/plugins-filters-split.html) along with some custom Ruby code most likely, especially if you want to do field manipulation like your _duration_ example.

Example:

```auto
filter {
    ruby {
        code => "
            event.set('clientName', event.get('clientName').split('/'))
            event.set('Duration', event.get('Duration').to_i / event.get('clientName').length)
        "
    }
    split {
        field => "clientName"
    }
}
```

---

<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:** [November 9, 2017, 1:36pm UTC](https://discuss.elastic.co/t/how-to-create-multiple-events-in-logstash-to-push-multiple-request-in-elasticsearch/103732/3 "2017-11-09T13:36:52Z")

</div>

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