Ruby exception occurred: event['field']) have been disabled

Hello,

I use this pattern to convert hexadecimal fields to decimal fields :

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

 ruby {
    code => 'event["hexa_value"] = event["hexa_value"].hex'
      }

I have this error message :

 Ruby exception occurred: Direct event field references (i.e. event['field']) have been disabled in favor of using event get and set methods

Documentation precognize set and get ?? I should to try line than :

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

?

Thank you for your help

Hi,

Try this:

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

Hey @Ruthu_Ramya ,

It doesn't work :confused:

The error message :

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

I use it to upload logs :

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

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

Thank you

Hi Beuhlet_Reseau,

In my earlier post, I try to indicate how to use the events with new Logstash version. The Ruby exception should be answered by a Ruby expert, I do not know Ruby.

Regards,
Ruthu

@Ruthu_Ramya

No no, I think the syntaxe is uncorrect. Have you even use ruby ?

@Beuhlet_Reseau,
I have never used Ruby.

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