# Fetch the value of a variable in logstash file

**URL:** <https://discuss.elastic.co/t/fetch-the-value-of-a-variable-in-logstash-file/142148>\
**Category:** Logstash\
**Created:** [July 30, 2018, 10:41am UTC](https://discuss.elastic.co/t/fetch-the-value-of-a-variable-in-logstash-file/142148 "2018-07-30T10:41:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![prashansa1](https://avatars.discourse-cdn.com/v4/letter/p/a3d4f5/32.png) [@prashansa1](https://discuss.elastic.co/u/prashansa1)\
**Post date:** [July 30, 2018, 10:41am UTC](https://discuss.elastic.co/t/fetch-the-value-of-a-variable-in-logstash-file/142148/1 "2018-07-30T10:41:22Z")

</div>

I'm trying to execute this code inside the filter block of ruby code.

filter {   
ruby {  
code =\> "  
test1= Amount  
test2=2  
test3=4

puts key1='map\_' +test1.to\_s + '_RULE_' + test2.to\_s + '_RANGE_' + test3.to\_s + '\_MIN'  
"  
}  
}

Created a variable 'map\_Amount\_2\_RANGE\_4\_MIN' using above mechanism  
and the value of this variable is given in ksh file  
map\_Amount\_2\_RANGE\_4\_MIN=2000

Now I want to print the value of 'map\_Amount\_2\_RANGE\_4\_MIN' in cof file ,How to print the value .  
I just tried  
puts key1  
but it's not working.

---

<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:** [August 27, 2018, 10:41am UTC](https://discuss.elastic.co/t/fetch-the-value-of-a-variable-in-logstash-file/142148/2 "2018-08-27T10:41:24Z")

</div>

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