# Logstash and JSON array split

**URL:** <https://discuss.elastic.co/t/logstash-and-json-array-split/247482>\
**Category:** Logstash\
**Created:** [September 4, 2020, 6:01am UTC](https://discuss.elastic.co/t/logstash-and-json-array-split/247482 "2020-09-04T06:01:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ranu\_shekhar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ranu_shekhar/32/50134_2.png) [@ranu\_shekhar](https://discuss.elastic.co/u/ranu_shekhar)\
**Post date:** [September 4, 2020, 6:01am UTC](https://discuss.elastic.co/t/logstash-and-json-array-split/247482/1 "2020-09-04T06:01:43Z")

</div>

Hi,  
I have the following input in JSON file:  
[{"id":"9906fce735f8282ef85ccd2e5d49cbd7d3aaef2c","short\_id":"9906fce7","created\_at":"2020-08-21T16:01:20.000+05:30","parent\_ids":"d4e1afec8e2069f514701697c7a6ffd4cda5fc74","5408be88fef3921c9eebacb7617c902d13dc062e","title":"Merge branch '1-nexenta-scaleio-ssu-health-check' into 'development'","message":"Merge branch '1-nexenta-scaleio-ssu-health-check' into 'development'\n\nResolve "Nexenta ScaleIO SSU Health Check"\n\nSee merge request nfvi-monitoring-automation/software-defined-storage-sds!4","author\_name":"Papinder Singh","author\_email":"papinder.a.singh","authored\_date":"2020-08-21T16:01:20.000+05:30","committer\_name":"Papinder Singh","committer\_email":"papinder.a.singh@..","committed\_date":"2020-08-21T16:01:20.000+05:30","/nfvi-monitoring-automation/software-defined-storage-sds/-/commit/9906fce735f8282ef85ccd2e5d49cbd7d3aaef2c"},{"id":"5408be88fef3921c9eebacb7617c902d13dc062e","short\_id":"5408be88","created\_at":"2020-08-21T15:57:48.000+05:30","parent\_ids":"d4e1afec8e2069f514701697c7a6ffd4cda5fc74","title":"Add new python script.. ","message":"Add new python script.. ","author\_name":"Papinder Singh","author\_email":"papinder.a.singh","authored\_date":"2020-08-21T15:57:48.000+05:30","committer\_name":"Papinder Singh","committer\_email":"papinder.a.singh","committed\_date":"2020-08-21T15:57:48.000+05:30","web\_url":"[http://gitlab](http://gitlab)"}

I am looking for creating multiple event based on this array:  
{"id":"9906fce735f8282ef85ccd2e5d49cbd7d3aaef2c","short\_id":"9906fce7","created\_at":"2020-08-21T16:01:20.000+05:30","parent\_ids":"d4e1afec8e2069f514701697c7a6ffd4cda5fc74","5408be88fef3921c9eebacb7617c902d13dc062e","title":"Merge branch '1-nexenta-scaleio-ssu-health-check' into 'development'","message":"Merge branch '1-nexenta-scaleio-ssu-health-check' into 'development'\n\nResolve "Nexenta ScaleIO SSU Health Check"\n\nSee merge request nfvi-monitoring-automation/software-defined-storage-sds!4","author\_name":"Papinder Singh","author\_email":"papinder.a.singh","authored\_date":"2020-08-21T16:01:20.000+05:30","committer\_name":"Papinder Singh","committer\_email":"papinder.a.singh","committed\_date":"2020-08-21T16:01:20.000+05:30","web\_url":"[http://gitlab](http://gitlab)"} ]

How to split the JSON line in order to have one event per build.

Thanks

---

<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:** [September 4, 2020, 1:22pm UTC](https://discuss.elastic.co/t/logstash-and-json-array-split/247482/2 "2020-09-04T13:22:46Z")

</div>

Use a json filter to parse the JSON, then use a split filter to separate the array into multiple events.

---

<div class="post-metadata">

**Author:** ![ranu\_shekhar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ranu_shekhar/32/50134_2.png) [@ranu\_shekhar](https://discuss.elastic.co/u/ranu_shekhar)\
**Post date:** [September 14, 2020, 3:05am UTC](https://discuss.elastic.co/t/logstash-and-json-array-split/247482/3 "2020-09-14T03:05:07Z")

</div>

Hi,  
I have tried this but this is not working.

---

<div class="post-metadata">

**Author:** ![pjanzen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pjanzen/32/13756_2.png) [@pjanzen](https://discuss.elastic.co/u/pjanzen)\
**Post date:** [September 14, 2020, 6:35am UTC](https://discuss.elastic.co/t/logstash-and-json-array-split/247482/4 "2020-09-14T06:35:59Z")

</div>

It is not working because you json is invalid. The field "parent\_ids" contain multiple values which are not in a list.

You need to come up with a way to either drop that field or transform it to valid json.

Paul.

---

<div class="post-metadata">

**Author:** ![ranu\_shekhar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ranu_shekhar/32/50134_2.png) [@ranu\_shekhar](https://discuss.elastic.co/u/ranu_shekhar)\
**Post date:** [September 18, 2020, 8:02am UTC](https://discuss.elastic.co/t/logstash-and-json-array-split/247482/5 "2020-09-18T08:02:29Z")

</div>

Hi,

I am able to drop the field now. But split filter is not working. Is there any way to parse this.

filter {  
json { source =\> source\_field}  
split { field =\> "[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 16, 2020, 8:02am UTC](https://discuss.elastic.co/t/logstash-and-json-array-split/247482/6 "2020-10-16T08:02:51Z")

</div>

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