Remove the last character of a string field


I have a string field named hostname, when the user have multiple instances I am getting an index in this field.

For example hostname looks like: toto1940,toto1941,toto1942.

I would like to remove the last element of my field and getting only toto194

Thanks for help

If that is a string you could do it using

dissect { mapping => { "message" => "%{host}0,%{}" } }
1 Like

Thank you Badger,

I resolved it by using ruby:

ruby {
code => "
   event.set('myhostname', event.get('hostname')[0..-2])

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