# Creating an array field with mutate

**URL:** <https://discuss.elastic.co/t/creating-an-array-field-with-mutate/88635>\
**Category:** Logstash\
**Created:** [June 7, 2017, 11:26pm UTC](https://discuss.elastic.co/t/creating-an-array-field-with-mutate/88635 "2017-06-07T23:26:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nileshgattani](https://avatars.discourse-cdn.com/v4/letter/n/4491bb/32.png) [@nileshgattani](https://discuss.elastic.co/u/nileshgattani)\
**Post date:** [June 7, 2017, 11:26pm UTC](https://discuss.elastic.co/t/creating-an-array-field-with-mutate/88635/1 "2017-06-07T23:26:33Z")

</div>

Hi,

I am writing logstash filters for log parsing, and at one step I am using elasticsearch input plugin. The elastic search input plugin expects hosts as an array.

Now, I am trying to access the hosts values as field. I have a mutate filter up in the chain that sets the values -  
mutate {  
add\_field =\> {"es\_host" =\> [":"}  
add\_field =\> {"es\_user" =\> ""}  
add\_field =\> {"es\_passwd" =\> ""}  
}

And then I try to access it as follows -

elasticsearch {  
hosts =\> [es\_host]  
user =\> "%{es\_user}"  
password =\> "%{es\_passwd}"  
query =\> "my\_query"  
}

Now, no matter what I do, es\_host never gets passed as an array.  
add\_field =\> {"es\_host" =\> ":"} , hosts =\> ["%{es\_host}"]  
add\_field =\> {"es\_host" =\> ":"} , hosts =\> [[es\_host]]  
add\_field =\> {["es\_host"] =\> ":"} , hosts =\> [es\_host]

And even setting the es\_host via ruby filter, but no luck. Every time it take es\_host as a literal and try to append the port by itself (http://es\_host:9200) .

Any clue?

Thanks  
-Nilesh

---

<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:** [June 8, 2017, 7:45pm UTC](https://discuss.elastic.co/t/creating-an-array-field-with-mutate/88635/2 "2017-06-08T19:45:16Z")

</div>

Yeah, I don't think this is possible.

---

<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:** [July 6, 2017, 7:46pm UTC](https://discuss.elastic.co/t/creating-an-array-field-with-mutate/88635/3 "2017-07-06T19:46:38Z")

</div>

Closed on July 6, 2017, 7:46pm UTC

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