Sign in to follow this  

Clear an alert with a NaN value

Recommended Posts

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;



Share this post

Link to post
Share on other sites

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

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this