# Keeping global variables in LS?!

**URL:** <https://discuss.elastic.co/t/keeping-global-variables-in-ls/39908>\
**Category:** Logstash\
**Created:** [January 22, 2016, 5:21pm UTC](https://discuss.elastic.co/t/keeping-global-variables-in-ls/39908 "2016-01-22T17:21:41Z")\
**Posts on this page:** 4\
**Page:** 2

<div class="post-metadata">

**Author:** ![jjdepaul](https://avatars.discourse-cdn.com/v4/letter/j/e0b2c6/32.png) [@jjdepaul](https://discuss.elastic.co/u/jjdepaul)\
**Post date:** [July 1, 2016, 6:18pm UTC](https://discuss.elastic.co/t/keeping-global-variables-in-ls/39908/21 "2016-07-01T18:18:28Z")

</div>

I updated the code as soon as posted it... because I tried to bring focus to what really counts above..... this line:  
`event['senderID'] = @@SenderId`

Here I am assigning a class variable I have kept into an event field 'senderID'....

---

<div class="post-metadata">

**Author:** ![jonyang](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@jonyang](https://discuss.elastic.co/u/jonyang)\
**Post date:** [April 7, 2017, 5:23pm UTC](https://discuss.elastic.co/t/keeping-global-variables-in-ls/39908/24 "2017-04-07T17:23:16Z")

</div>

my log file data looks something like this:  
line 1: date time field; server name + other fields  
subsequent lines: ( details )  
i used the above suggestions successfully saved class variables @@ldate, @@server from the first line :  
ruby {  
init =\> "@@ldate='', @@server='' "  
code =\> "@@ldate=event['ldate'], @@server=event['server']"  
}  
and added these two properties in subsequent detail lines:  
ruby { code =\> "event['ldate'] = @@ldate, event['server'] = @@server" }

however, the values of these properties are in array format. what i am expecting are string.  
"ldate" =\> [  
[0] "2017-03-22 02:15:10",  
[1] "2017-03-22 02:15:10"],

please help

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [April 7, 2017, 11:48pm UTC](https://discuss.elastic.co/t/keeping-global-variables-in-ls/39908/25 "2017-04-07T23:48:50Z")

</div>

Please start your own thread.

---

<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, 4:27am UTC](https://discuss.elastic.co/t/keeping-global-variables-in-ls/39908/26 "2017-07-06T04:27:15Z")

</div>

Closed on July 6, 2017, 4:27am UTC



[Previous page](https://discuss.elastic.co/t/keeping-global-variables-in-ls/39908.md?page=1)
