How to compare 2 numerical field values with each other?

Hi,

Is it possible to load the value of a field and use that to compare it to another field and based on that add a new field with a value?

E.g.

if [temperature] > [alert1] 
  add field "outcome => normal"
if else [temperature] > [alert2]
   add field "outcome => high"

Something like the below will work but it will be a lot of work to maintain as I have many different alert values. The above should be more flexible as I'd only need one line for each alert.

if [alert1] == "1000" and temperature >1000 
 add field "outcome => normal"

To anwser my own question and in case anyone is every looking to do something similar, I got it working using this piece if ruby.

 ruby {
           code => "
             if event.get('temperature').to_i >= event.get('alert1').to_i
               event.set('outcome', 'normal');
             end
           "
         }

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