# Get the Value of an array, in the output config

**URL:** <https://discuss.elastic.co/t/get-the-value-of-an-array-in-the-output-config/121404>\
**Category:** Logstash\
**Created:** [February 25, 2018, 7:14pm UTC](https://discuss.elastic.co/t/get-the-value-of-an-array-in-the-output-config/121404 "2018-02-25T19:14:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maher\_Ben\_Taleb\_Ali](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/maher_ben_taleb_ali/32/26774_2.png) [@Maher\_Ben\_Taleb\_Ali](https://discuss.elastic.co/u/Maher_Ben_Taleb_Ali)\
**Post date:** [February 25, 2018, 7:14pm UTC](https://discuss.elastic.co/t/get-the-value-of-an-array-in-the-output-config/121404/1 "2018-02-25T19:14:42Z")

</div>

Hi,

I have the corresponding config file :

```
input {
  elasticsearch {
    hosts => "localhost"
    index => "articles"
    add_field => { "[@metadata][kafka_topics]" => ["test1", "test2"] }
  }
}
output {
  stdout { codec => rubydebug{
      metadata => true
    } }
  kafka {
    topic_ids => "%{[@metadata][kafka_topics]}"
  }
}

```

I have changed the output plugin for kafka so now it is supporting arrays .  
topic\_ids =\> ["test1","test2"] works smoothly.  
but when I try to access the value of the variable it is treated as a string no matter what I try.

---

<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:** [February 25, 2018, 8:33pm UTC](https://discuss.elastic.co/t/get-the-value-of-an-array-in-the-output-config/121404/2 "2018-02-25T20:33:38Z")

</div>

Yes, I don't think there's a way around this. Logstash's configuration language is primitive.

---

<div class="post-metadata">

**Author:** ![Maher\_Ben\_Taleb\_Ali](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/maher_ben_taleb_ali/32/26774_2.png) [@Maher\_Ben\_Taleb\_Ali](https://discuss.elastic.co/u/Maher_Ben_Taleb_Ali)\
**Post date:** [February 25, 2018, 8:47pm UTC](https://discuss.elastic.co/t/get-the-value-of-an-array-in-the-output-config/121404/3 "2018-02-25T20:47:47Z")

</div>

yes,  
Is there a way to split the string by ',' in the output config ?  
else, can I do something to change how the "%{}" works?

---

<div class="post-metadata">

**Author:** ![Maher\_Ben\_Taleb\_Ali](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/maher_ben_taleb_ali/32/26774_2.png) [@Maher\_Ben\_Taleb\_Ali](https://discuss.elastic.co/u/Maher_Ben_Taleb_Ali)\
**Post date:** [February 26, 2018, 12:13am UTC](https://discuss.elastic.co/t/get-the-value-of-an-array-in-the-output-config/121404/4 "2018-02-26T00:13:13Z")

</div>

I ended up splitting the array inside the kafka's output plugin.  
thanks for the help.

---

<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:** [March 26, 2018, 12:13am UTC](https://discuss.elastic.co/t/get-the-value-of-an-array-in-the-output-config/121404/5 "2018-03-26T00:13:35Z")

</div>

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