# Array field in event

**URL:** <https://discuss.elastic.co/t/array-field-in-event/68475>\
**Category:** Logstash\
**Created:** [December 8, 2016, 7:46pm UTC](https://discuss.elastic.co/t/array-field-in-event/68475 "2016-12-08T19:46:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kahndor](https://avatars.discourse-cdn.com/v4/letter/k/97f17d/32.png) [@kahndor](https://discuss.elastic.co/u/kahndor)\
**Post date:** [December 8, 2016, 7:46pm UTC](https://discuss.elastic.co/t/array-field-in-event/68475/1 "2016-12-08T19:46:56Z")

</div>

I have an event that has many fields. These fields need to be arrays with other fields. Here is an example of what I want:

```
"//ip//dst" : [ {
      "type" : "ipv4",
      "value" : "192.168.1.2",
      "vis" : "U&FOUO"
    } ],

```

I cannot seem to get Logstash to do this. It will only group the type, value, and vis fields in curly braces {} and not brackets [].

Perhaps I am missing something simple or is this not possible?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [December 9, 2016, 6:34am UTC](https://discuss.elastic.co/t/array-field-in-event/68475/2 "2016-12-09T06:34:28Z")

</div>

What does the input look like? What results are you currently getting? What does your configuration look like?

---

<div class="post-metadata">

**Author:** ![kahndor](https://avatars.discourse-cdn.com/v4/letter/k/97f17d/32.png) [@kahndor](https://discuss.elastic.co/u/kahndor)\
**Post date:** [December 9, 2016, 12:18pm UTC](https://discuss.elastic.co/t/array-field-in-event/68475/3 "2016-12-09T12:18:11Z")

</div>

Thank you for the reply. The input is a CSV which I parse using the csv filter

> ```
> csv {
> separator => ','
> columns => ["src_dot", "dst_dot", ...]
> }
> 
> ```

I am then renaming the inputs in a different format. For example dst\_dot becomes //ip//dst as in the OP. And the value from the csv goes in the value field within the array that I want.

> ```
> rename => { "dst_dot" => "[fields][//ip//dst][value]" }
> 
> ```

I am then manually marking up the value with metadata such as type and vis

> ```
> add_field => {"[fields][//ip//dst][type]" => "ipv4"}
> add_field => {"[fields][//ip//dst][vis]" => "U"}
> 
> ```

All of this produces the following object:

> ```
> fields: {
> "//ip//dst" : {
> "type" : "ipv4",
> "value" : "192.168.1.2",
> "vis" : "U"
> } ,
> 
> ```

I need to have the brackets encasing the type, value, and vis fields as in the OP.

I hope that help explain what is happening.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [December 9, 2016, 12:32pm UTC](https://discuss.elastic.co/t/array-field-in-event/68475/4 "2016-12-09T12:32:30Z")

</div>

I suspect you'll have to use a ruby filter to get exactly what you want.

---

<div class="post-metadata">

**Author:** ![kahndor](https://avatars.discourse-cdn.com/v4/letter/k/97f17d/32.png) [@kahndor](https://discuss.elastic.co/u/kahndor)\
**Post date:** [December 9, 2016, 12:48pm UTC](https://discuss.elastic.co/t/array-field-in-event/68475/5 "2016-12-09T12:48:34Z")

</div>

Thank you. I will look into that.

---

<div class="post-metadata">

**Author:** ![kahndor](https://avatars.discourse-cdn.com/v4/letter/k/97f17d/32.png) [@kahndor](https://discuss.elastic.co/u/kahndor)\
**Post date:** [December 9, 2016, 5:06pm UTC](https://discuss.elastic.co/t/array-field-in-event/68475/6 "2016-12-09T17:06:05Z")

</div>

In case anyone else is needing a solution for this problem. This is the ruby filter I used

```
ruby {
	code => " event['fields'].each_key { |key| event['fields'][key] = [event['fields'][key]] } "			
}
```

---

<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 6, 2017, 5:07pm UTC](https://discuss.elastic.co/t/array-field-in-event/68475/7 "2017-01-06T17:07:17Z")

</div>

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