Help me to convert hexa in decimal value

Hello, i search to convert hexa value in decimal value for performing.

I have found a ruby code in disucss but it's seems to be fail.

I use it to upload logs :

 mutate {
  convert => { "hexa_value" => "integer" }
       }

 ruby {
  code => "event.set('hexa_value', event.get('hexa_value').hex)"
      }

The error message :

 [ERROR][logstash.filters.ruby    ] Ruby exception occurred: undefined method `hex' for 2:Fixnum

Thank you

1 Like

Try .to_s.hex instead of .hex.

@magnusbaeck You are a god :slight_smile:

For everyone who search to convert hexa value in decimal value this code is ok :

ruby {
  code => "event.set('your_hexa_value', event.get('your_hexa_value').to_s.hex)"
     }

In Output your hexa value become a decimal value !

Thank a lots

2 Likes

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