# How to create Arrays and Loop them such as "FOR" in logstash config file

**URL:** <https://discuss.elastic.co/t/how-to-create-arrays-and-loop-them-such-as-for-in-logstash-config-file/145352>\
**Category:** Logstash\
**Created:** [August 21, 2018, 10:12am UTC](https://discuss.elastic.co/t/how-to-create-arrays-and-loop-them-such-as-for-in-logstash-config-file/145352 "2018-08-21T10:12:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![snehabh](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@snehabh](https://discuss.elastic.co/u/snehabh)\
**Post date:** [August 21, 2018, 10:12am UTC](https://discuss.elastic.co/t/how-to-create-arrays-and-loop-them-such-as-for-in-logstash-config-file/145352/1 "2018-08-21T10:12:59Z")

</div>

I am new to ELK and need help to understand and execute the code.

## I need to create two arrays Array1--\>Errcode {E00,E001,E002} Array2--\>ErrorShortDesc {a1,a2,a3,a4,a5,a6,a7} now based to the above array values i need to find actual Error-description based on the permutation combination.

## For(int i,Errcode[i],i++) { For(int j,ErrorShortDesc[j],j++) { set of Ifs to find exact error description } }

How can we achieve this in Logstash file  
have used grok to do the pattern matching to get ErrorCode and ErrorshortDescription but now need to array it.  
Currently having a big if else ladder.

---

<div class="post-metadata">

**Author:** ![\_Alex](https://avatars.discourse-cdn.com/v4/letter/_/54ee81/32.png) [@\_Alex](https://discuss.elastic.co/u/_Alex)\
**Post date:** [August 21, 2018, 10:30am UTC](https://discuss.elastic.co/t/how-to-create-arrays-and-loop-them-such-as-for-in-logstash-config-file/145352/2 "2018-08-21T10:30:41Z")

</div>

Could you make use of the [translate filter](https://www.elastic.co/guide/en/logstash/current/plugins-filters-translate.html) instead of using the big else if ladder?

---

<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:** [September 18, 2018, 10:30am UTC](https://discuss.elastic.co/t/how-to-create-arrays-and-loop-them-such-as-for-in-logstash-config-file/145352/3 "2018-09-18T10:30:44Z")

</div>

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