Add field with the length of value of other field


(Sito) #1

Hi all,

I'm trying to create a new field which value must be the length of the string of another field.
I have found an advice using ruby code, like this:

//ruby {
// code => "event.set['http_user_agent_length'] = event.get['http_user_agent'].length"
// }
// }
the type of "http_user_agent" is string.

When I execute this code, I receive this message:

[ERROR] 2018-09-20 08:19:13.047 [Ruby-0-Thread-7: :1] ruby - Ruby exception occurred: wrong number of arguments calling set (0 for 2)

Anyone know the issue or other way to obtain the length of a field?

Thank you,

Best Regards


(Sito) #2

Hi again,
I get the solution. I have used this code and work it:
//
ruby {
code => 'event.set("http_user_agent_lenght",event.get("http_user_agent").length)'
}
//

Thanks,

Regards


(system) #3

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