Clear an alert with a NaN value


Recommended Posts

  • LogicMonitor Staff

I recently wrote a datasource that pulled an API and alerted when the return value was greater than 0

The problem I ran into is the API never returned a 0, instead it would return NaN.  I worked around this issue by using Key = Value datapoints and a "if (strv.isEmpty) {" statement.  Basically, if their is a value returned the output in the script will be "events=[returned value]" the same as most key=value datapoints.  If the returned value is empty, the script will fill out the entire string returning "events=0" which puts a 0 in the datapoint and allows the alert to clear.  

This a nice workaround for a LogicMonitor Admin's bag of tricks.  


//Print KeyValue
strv = response_obj['results']['2'];

 if ( strv.isEmpty() )      { 
      println "events=0"
} else {

       println "events=" + strv;



Link to post
Share on other sites
  • 2 weeks later...
  • LogicMonitor Staff

In addition to that, in cases where you are not groovying or other calculations returns a NAN, you can also make a complex datapoint with 

if(un(datapoint_name),0,datapoint_name) and alert on that

Link to post
Share on other sites


This topic is now archived and is closed to further replies.