# How to merge different objects inside the same event

**URL:** <https://discuss.elastic.co/t/how-to-merge-different-objects-inside-the-same-event/158389>\
**Category:** Logstash\
**Created:** [November 27, 2018, 5:17pm UTC](https://discuss.elastic.co/t/how-to-merge-different-objects-inside-the-same-event/158389 "2018-11-27T17:17:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![josemaia](https://avatars.discourse-cdn.com/v4/letter/j/bcef8e/32.png) [@josemaia](https://discuss.elastic.co/u/josemaia)\
**Post date:** [November 27, 2018, 5:17pm UTC](https://discuss.elastic.co/t/how-to-merge-different-objects-inside-the-same-event/158389/1 "2018-11-27T17:17:01Z")

</div>

Hello! I have a fairly complex JSON object as an input, and I want to flatten it so it's easier to work with in Kibana.

An example is below:

```
{
  "sprints": [
    {
      "id": 17193,
      "sequence": 17193,
      "name": "Sprint 12",
      "state": "CLOSED"
    },
    {
      "id": 16510,
      "sequence": 16510,
      "name": "Sprint 11",
      "state": "CLOSED"
    }
  ],
  "velocityStatEntries": {
    "16510": {
      "estimated": {
        "value": 49
      },
      "completed": {
        "value": 36
      }
    },
    "17193": {
      "estimated": {
        "value": 52
      },
      "completed": {
        "value": 70
      }
    }
  }
}

```

Ideally I would want to, given the name of the objects inside **[velocityStatEntries]**, find the object in **[sprints]** with that ID and add the estimated/completed values there. However, if it's easier, the other way around would also make sense.

Am I looking at a complex ruby script to do this, or am I missing a feature that would let me handle this quickly? Or am I going about this in the entirely wrong way and this data is actually in a format that Kibana/Grafana/Elastic can already work with easily?

Thanks.

EDIT:

- the information is coming in through http\_poller

---

<div class="post-metadata">

**Author:** ![josemaia](https://avatars.discourse-cdn.com/v4/letter/j/bcef8e/32.png) [@josemaia](https://discuss.elastic.co/u/josemaia)\
**Post date:** [November 28, 2018, 5:29pm UTC](https://discuss.elastic.co/t/how-to-merge-different-objects-inside-the-same-event/158389/2 "2018-11-28T17:29:06Z")

</div>

FWIW, the Ruby solution is simple:

```
  ruby {
    code => "
        sprintId = event.get('[sprints][id]');
        estimated = event.get('[velocityStatEntries]['+(sprintId).to_s+'][estimated][value]');
        completed = event.get('[velocityStatEntries]['+(sprintId).to_s+'][completed][value]');
        event.set('[sprints][estimatedUnits]', estimated);
        event.set('[sprints][completedUnits]', completed);
      "
  }
```

---

<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:** [December 26, 2018, 5:29pm UTC](https://discuss.elastic.co/t/how-to-merge-different-objects-inside-the-same-event/158389/3 "2018-12-26T17:29:09Z")

</div>

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