Can't do division between two floats

Hello.
This is the code I have.

mutate {convert => ["Average Time of Execution", "float"]}
mutate {convert => ["Average Time of Execution - Last Hour", "float"]}

ruby {
code => "event['last Hour Perc'] = event['Average Time of Execution'] / event['Average Time of Execution - Last Hour']"
}

But i'm getting the following error when I execute.

Ruby exception occurred: undefined method '/' for ...

How do I solve this? Thank you.

Please show the full error message. Are you sure the Average Time of Execution field exists for all events?

1 Like

Full error:

Ruby exception occurred: undefined method '/' for [57000.0]: Array {:level=> error}
Got this error multiple times and the number 57000 differs. And yes, I've been getting those values without any problem,

The problem is that the field is an array and not a singular float value.

1 Like

I'm sorry, but how do I access that value?

event['Average Time of Execution'][0] accesses the first (and in this case only) element of the array. Depending on how it ends up as an array there might be a way to it being an array.

2 Likes

Totally worked. You're the man :slight_smile: Cheers