Logstash and JSON array split

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"}

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"} ]

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

Thanks

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

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

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.

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]" }
}

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