# Dynamically create nested objects from a log record

**URL:** <https://discuss.elastic.co/t/dynamically-create-nested-objects-from-a-log-record/211357>\
**Category:** Elasticsearch\
**Created:** [December 10, 2019, 6:30pm UTC](https://discuss.elastic.co/t/dynamically-create-nested-objects-from-a-log-record/211357 "2019-12-10T18:30:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![agx](https://avatars.discourse-cdn.com/v4/letter/a/e19adc/32.png) [@agx](https://discuss.elastic.co/u/agx)\
**Post date:** [December 10, 2019, 6:30pm UTC](https://discuss.elastic.co/t/dynamically-create-nested-objects-from-a-log-record/211357/1 "2019-12-10T18:30:05Z")

</div>

i'm having trouble wrapping my head around how i would go about transforming some items in a log line into nested objects (or whether it's even worthwhile)

its a custom NGINX log that logs upstream connections and the time to response, and there are times when i end up with multiple upstream destinations and response times in one log line, like this:

2019-12-10T12:23:23-05:00 | 10.0.0.1, 10.0.0.2 | [0.06, 0.07] | [api.whatever.com](http://api.whatever.com)

Where:

10.0.0.1 and response time 0.06 are associated and  
10.0.0.2 and response time 0.07 are associated

so I was thinking an array of nested objects would be ideal here.

`@timestamp: "2019-12-10T12:23:23-05:00", nginx.gateway.upstream: [{ ip: 10.0.0.1, response_time: 0.06 }, { ip: 10.0.0.2, response_time: 0.07 }], host: "api.whatever.com"`

when i parse the log, I can parse the IPs into a list variable: nginx.gateway.upstream.ip\_list  
and the response\_times into a similar list: nginx.gateway.upstream.response\_time\_list

but i'm not sure how to go from those lists to nested objects. log entries may have only one upstream, or multiple.

i think its worth maintaining the associations so i can trace delays back to the appropriate upstream source.

i guess i should add that I'm using an ingest pipeline to do the parsing and transformations.

---

<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:** [January 7, 2020, 6:30pm UTC](https://discuss.elastic.co/t/dynamically-create-nested-objects-from-a-log-record/211357/2 "2020-01-07T18:30:13Z")

</div>

Closed on January 7, 2020, 6:30pm UTC

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