# Lowercase a field's value

**URL:** <https://discuss.elastic.co/t/lowercase-a-fields-value/41025>\
**Category:** Logstash\
**Created:** [February 5, 2016, 7:20am UTC](https://discuss.elastic.co/t/lowercase-a-fields-value/41025 "2016-02-05T07:20:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kartik\_Ramachandran](https://avatars.discourse-cdn.com/v4/letter/k/839c29/32.png) [@Kartik\_Ramachandran](https://discuss.elastic.co/u/Kartik_Ramachandran)\
**Post date:** [February 5, 2016, 7:20am UTC](https://discuss.elastic.co/t/lowercase-a-fields-value/41025/1 "2016-02-05T07:20:22Z")

</div>

I am trying to lowercase the value of only 1 filed in logstash. From the old threads, i see that the lowercase filter does not help. So, i tried using

ruby {  
code =\> "event.to\_hash.each{|k, v| v.downcase! if v.is\_a?(String)}"  
}

But the above lowercases all fields.

If i try using event['field'].to... ==\> i get the error  
Ruby exception occurred: undefined method `to\_hash' for nil:NilClass {:level=\>:error, :file=\>"logstash/filters/ruby.rb", :line=\>"41", :method=\>"filter"}

How can i lowercase the value of ONLY one field after i parse the message?

Please let me know.

Thanks.

---

<div class="post-metadata">

**Author:** ![Kartik\_Ramachandran](https://avatars.discourse-cdn.com/v4/letter/k/839c29/32.png) [@Kartik\_Ramachandran](https://discuss.elastic.co/u/Kartik_Ramachandran)\
**Post date:** [February 5, 2016, 8:00am UTC](https://discuss.elastic.co/t/lowercase-a-fields-value/41025/2 "2016-02-05T08:00:19Z")

</div>

with the new logstash release, lowercase works fine.

thanks.

---

<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, 5:12am UTC](https://discuss.elastic.co/t/lowercase-a-fields-value/41025/3 "2017-07-06T05:12:57Z")

</div>


