# Does logstash support having a list/array in root (top level) of the event

**URL:** <https://discuss.elastic.co/t/does-logstash-support-having-a-list-array-in-root-top-level-of-the-event/283524>\
**Category:** Logstash\
**Created:** [September 7, 2021, 11:19am UTC](https://discuss.elastic.co/t/does-logstash-support-having-a-list-array-in-root-top-level-of-the-event/283524 "2021-09-07T11:19:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Renjith\_PK](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/renjith_pk/32/94239_2.png) [@Renjith\_PK](https://discuss.elastic.co/u/Renjith_PK)\
**Post date:** [September 7, 2021, 11:19am UTC](https://discuss.elastic.co/t/does-logstash-support-having-a-list-array-in-root-top-level-of-the-event/283524/1 "2021-09-07T11:19:43Z")

</div>

We have input data like this `message:[{key1:value1},{key2:value2}]`  
and we need value of message, which is a list, directly on root of event (to use as zipkin storage) without any additional field.  
I tried using json filter,

```auto
filter {
  if [type] == "tracing" {
    json {
      source => "message"
      skip_on_invalid_json => true
      remove_field => ["message"]
    }
 }
}

output {
  if [type] == "tracing" {
    elasticsearch {
      hosts => ["${ELASTIC_HOST}"]
      index => "tracing-%{+YYYY.MM.dd}"
    }
  }
}

```

Here without target, which ideally should move value of message to root of event, but I get error `Parsed JSON object/hash requires a target configuration option`

---

<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 7, 2021, 1:09pm UTC](https://discuss.elastic.co/t/does-logstash-support-having-a-list-array-in-root-top-level-of-the-event/283524/2 "2021-09-07T13:09:45Z")

</div>

Your JSON is an array. logstash is telling you that the array has to have a name.

What do you want to event to look like?

---

<div class="post-metadata">

**Author:** ![Renjith\_PK](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/renjith_pk/32/94239_2.png) [@Renjith\_PK](https://discuss.elastic.co/u/Renjith_PK)\
**Post date:** [September 7, 2021, 2:27pm UTC](https://discuss.elastic.co/t/does-logstash-support-having-a-list-array-in-root-top-level-of-the-event/283524/3 "2021-09-07T14:27:06Z")

</div>

Expected event format

```auto
[{key1:value1},{key2:value2}]

```

Basically zipkin wanted to consume it from elasticsearch and list is what it requires.  
Here is a similar discussion - [Logstash Filter Json To Array of Json - #6 by Badger](https://discuss.elastic.co/t/logstash-filter-json-to-array-of-json/181345/6) but in my case output is elasticsearch I don't think I can use `codec => plain { format => "[%{[@metadata][string]}`

---

<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 7, 2021, 2:33pm UTC](https://discuss.elastic.co/t/does-logstash-support-having-a-list-array-in-root-top-level-of-the-event/283524/4 "2021-09-07T14:33:31Z")

</div>

You cannot have an array at the top level of an event.

---

<div class="post-metadata">

**Author:** ![Renjith\_PK](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/renjith_pk/32/94239_2.png) [@Renjith\_PK](https://discuss.elastic.co/u/Renjith_PK)\
**Post date:** [September 7, 2021, 2:35pm UTC](https://discuss.elastic.co/t/does-logstash-support-having-a-list-array-in-root-top-level-of-the-event/283524/5 "2021-09-07T14:35:29Z")

</div>

Thanks @Badger we will see some other alternatives

---

<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 5, 2021, 2:36pm UTC](https://discuss.elastic.co/t/does-logstash-support-having-a-list-array-in-root-top-level-of-the-event/283524/6 "2021-10-05T14:36:22Z")

</div>

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