• 0
Sign in to follow this  
Jeroen Gouma

Number of alerts on dashboard

Question

I have a request to report the number of alerts (within a group, (customer)) on a management dashboard per day.

I'm thinking of putting a line graph which gives the number of events per day (1 line per severity) on a cumulated number of the specific group.

Big question: How can i calculate this number? Any ideas?

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0

You can use our RPC API to to get the number of alerts per severity: http://www.logicmonitor.com/support/rpc-api-developers-guide/manage-alerts/get-alerts/

You could write a simple script datasource that makes the getAlerts API calls and reports the number of alerts per severity, and then displays the data in a dashboard widget.

Share this post


Link to post
Share on other sites
  • 0

I might have an easier way..

Call this script directly then parse the output.

I included my datasource I created as well as XML for input into a datasource in your portal.

To have this for multiple 'groupIds' you may need to change things up (a little perl changes) by perhaps using a groovy script to pass in a variable (groupId?) for the different customers you wish to build this for. Shouldn't be hard.

#!/usr/bin/env perl

### this is the perl script you should call to output the count
### as needed

# replace username with an administrative username
# replace the password with .. the password of the user
# example below works
# don't forget to update the groupId as needed! Perhaps make it
#   a passed parameter via groovy script directly

$userName="mike";
$password="pass.w0rd";
$sitename="sitename";
$siteurl="site.logicmonitor.com"
$groupId="1";

$curlopt="'https://$siteurl/santaba/rpc/getAlerts?c=$sitename&u=$userName&p=$password&hostGroupId=$groupId'";

$curlrun="env curl -s $curlopt";

# Now we have the command to run

$alertwarn=;
$alerterr=;
$alertcrit=;

open(FILE, "-|", $curlrun) or die $!;

while (<FILE>) {
  $alertwarn++ if /warn/;
  $alerterr++ if /error/;
  $alertcrit++ if /critical/;
}
close $handle;

$alerttotal=$alertwarn+$alerterr+$alertcrit;

print "warning:" . $alertwarn . "\n";
print "error:" . $alerterr . "\n";
print "critical:" . $alertcrit . "\n";
print "total:" . $alerttotal . "\n";
<?xml version="1.0" encoding="UTF-8" ?>
<feed  version="1.0" hasPendingRequests="false" >
  <company></company>
  <status>200</status>
  <errmsg>OK</errmsg>
  <interval></interval>
    <entry type="predatasource">
        <version>1391573679</version>
        <name>Count Alerts</name>
        <displayedas>_Count Alerts</displayedas>
        <description>Count number of alerts from LogicMonitor.

Gathers warnings, errors, criticals, and a total number.</description>
        <collector>script</collector>
        <hasMultiInstances>false</hasMultiInstances>
        <schedule>600</schedule>
        <appliesTo>system.hostname == &#34;insert-IP-here&#34; or system.hostname == &#34;insert-FQDN-here&#34;</appliesTo>
        <wildcardauto>false</wildcardauto>
        <wildcardpersist>false</wildcardpersist>
        <wildcardlinuxscript></wildcardlinuxscript>
        <wildcardlinuxcmdline></wildcardlinuxcmdline>
        <wildcardwinscript></wildcardwinscript>
        <wildcardwincmdline></wildcardwincmdline>
        <wildcardgroovyscript></wildcardgroovyscript>
        <wildcardschedule>1440</wildcardschedule>
        <wildcarddisable>false</wildcarddisable>
        <agdmethod>none</agdmethod>
        <agdparams></agdparams>
        <group></group>
        <tags></tags>
        <technology></technology>
        <adlist><![CDATA[{"id":0,"agdmethod":"none","params":{},"agdparams":"","filters":[]}]]></adlist>
        <attributes>
        <attribute>
            <name>scripttype</name>
            <value>file</value>
            <comment></comment>
        </attribute>
        <attribute>
            <name>scriptgroovy</name>
            <value>import com.santaba.agent.groovyapi.expect.Expect;
import com.santaba.agent.groovyapi.snmp.Snmp;
import com.santaba.agent.groovyapi.http.*;
import com.santaba.agent.groovyapi.jmx.*;
import org.xbill.DNS.*;</value>
            <comment></comment>
        </attribute>
        <attribute>
            <name>windowsscript</name>
            <value></value>
            <comment></comment>
        </attribute>
        <attribute>
            <name>linuxscript</name>
            <value>/usr/local/logicmonitor/agent/lib/count-alerts.pl</value>
            <comment></comment>
        </attribute>
        <attribute>
            <name>windowscmdline</name>
            <value></value>
            <comment></comment>
        </attribute>
        <attribute>
            <name>linuxcmdline</name>
            <value></value>
            <comment></comment>
        </attribute>
        </attributes>
        <datapoints>
        <datapoint>
            <name>alertwarn</name>
            <dataType>7</dataType>
            <type>2</type>
            <postprocessormethod>namevalue</postprocessormethod>
            <postprocessorparam>warning</postprocessorparam>
            <usevalue>output</usevalue>
            <alertexpr>&#62; 100</alertexpr>
            <alertmissing>1</alertmissing>
            <alertsubject></alertsubject>
            <alertbody></alertbody>
            <description></description>
            <maxvalue></maxvalue>
            <minvalue></minvalue>
            <userparam1></userparam1>
            <userparam2></userparam2>
            <userparam3></userparam3>
            <iscomposite>false</iscomposite>
            <rpn></rpn>
            <alertTransitionIval>2</alertTransitionIval>
            <alertClearTransitionIval></alertClearTransitionIval>
        </datapoint>
        <datapoint>
            <name>alerterror</name>
            <dataType>7</dataType>
            <type>2</type>
            <postprocessormethod>namevalue</postprocessormethod>
            <postprocessorparam>error</postprocessorparam>
            <usevalue>output</usevalue>
            <alertexpr>&#62; 35 50</alertexpr>
            <alertmissing>1</alertmissing>
            <alertsubject></alertsubject>
            <alertbody></alertbody>
            <description></description>
            <maxvalue></maxvalue>
            <minvalue></minvalue>
            <userparam1></userparam1>
            <userparam2></userparam2>
            <userparam3></userparam3>
            <iscomposite>false</iscomposite>
            <rpn></rpn>
            <alertTransitionIval>2</alertTransitionIval>
            <alertClearTransitionIval></alertClearTransitionIval>
        </datapoint>
        <datapoint>
            <name>alertcritical</name>
            <dataType>7</dataType>
            <type>2</type>
            <postprocessormethod>namevalue</postprocessormethod>
            <postprocessorparam>critical</postprocessorparam>
            <usevalue>output</usevalue>
            <alertexpr>&#62; 4 4 5</alertexpr>
            <alertmissing>1</alertmissing>
            <alertsubject></alertsubject>
            <alertbody></alertbody>
            <description></description>
            <maxvalue></maxvalue>
            <minvalue></minvalue>
            <userparam1></userparam1>
            <userparam2></userparam2>
            <userparam3></userparam3>
            <iscomposite>false</iscomposite>
            <rpn></rpn>
            <alertTransitionIval>2</alertTransitionIval>
            <alertClearTransitionIval></alertClearTransitionIval>
        </datapoint>
        <datapoint>
            <name>alerttotal</name>
            <dataType>7</dataType>
            <type>2</type>
            <postprocessormethod>namevalue</postprocessormethod>
            <postprocessorparam>total</postprocessorparam>
            <usevalue>output</usevalue>
            <alertexpr></alertexpr>
            <alertmissing>1</alertmissing>
            <alertsubject></alertsubject>
            <alertbody></alertbody>
            <description></description>
            <maxvalue></maxvalue>
            <minvalue></minvalue>
            <userparam1></userparam1>
            <userparam2></userparam2>
            <userparam3></userparam3>
            <iscomposite>false</iscomposite>
            <rpn></rpn>
            <alertTransitionIval>5</alertTransitionIval>
            <alertClearTransitionIval></alertClearTransitionIval>
        </datapoint>
        </datapoints>
        <graphs>
        <graph>
            <name>Alert Trending</name>
            <title>Alert Trending</title>
            <verticallabel>number</verticallabel>
            <rigid>true</rigid>
            <maxvalue>NaN</maxvalue>
            <minvalue>0.0</minvalue>
            <displayprio>1</displayprio>
            <timescale>1day</timescale>
            <base1024>false</base1024>
            <graphdatapoints>
        <graphdatapoint>
            <name>alertcritical</name>
            <datapointname>alertcritical</datapointname>
            <cf>2</cf>
        </graphdatapoint>
        <graphdatapoint>
            <name>alerterror</name>
            <datapointname>alerterror</datapointname>
            <cf>2</cf>
        </graphdatapoint>
        <graphdatapoint>
            <name>alerttotal</name>
            <datapointname>alerttotal</datapointname>
            <cf>2</cf>
        </graphdatapoint>
        <graphdatapoint>
            <name>alertwarn</name>
            <datapointname>alertwarn</datapointname>
            <cf>2</cf>
        </graphdatapoint>
            </graphdatapoints>
            <graphvirtualdatapoints>
            </graphvirtualdatapoints>
            <graphdatas>
            <graphdata>
                <type>2</type>
                <legend>Total</legend>
                <color>black</color>
                <datapointname>alerttotal</datapointname>
                <isvirtualdatapoint>false</isvirtualdatapoint>
            </graphdata>
            <graphdata>
                <type>1</type>
                <legend>Warnings</legend>
                <color>yellow</color>
                <datapointname>alertwarn</datapointname>
                <isvirtualdatapoint>false</isvirtualdatapoint>
            </graphdata>
            <graphdata>
                <type>1</type>
                <legend>Errors</legend>
                <color>orange</color>
                <datapointname>alerterror</datapointname>
                <isvirtualdatapoint>false</isvirtualdatapoint>
            </graphdata>
            <graphdata>
                <type>1</type>
                <legend>Criticals</legend>
                <color>red</color>
                <datapointname>alertcritical</datapointname>
                <isvirtualdatapoint>false</isvirtualdatapoint>
            </graphdata>
            </graphdatas>
        </graph>
        </graphs>
        <overviewgraphs>
        </overviewgraphs>
    </entry>
</feed>

 

Share this post


Link to post
Share on other sites
  • 0
On 5/1/2016 at 11:24 PM, Michael Horwath said:

I might have an easier way..

Call this script directly then parse the output.

I included my datasource I created as well as XML for input into a datasource in your portal.

To have this for multiple 'groupIds' you may need to change things up (a little perl changes) by perhaps using a groovy script to pass in a variable (groupId?) for the different customers you wish to build this for. Shouldn't be hard.


#!/usr/bin/env perl

### this is the perl script you should call to output the count
### as needed

# replace username with an administrative username
# replace the password with .. the password of the user
# example below works
# don't forget to update the groupId as needed! Perhaps make it
#   a passed parameter via groovy script directly

$userName="mike";
$password="pass.w0rd";
$sitename="sitename";
$siteurl="site.logicmonitor.com"
$groupId="1";

$curlopt="'https://$siteurl/santaba/rpc/getAlerts?c=$sitename&u=$userName&p=$password&hostGroupId=$groupId'";

$curlrun="env curl -s $curlopt";

# Now we have the command to run

$alertwarn=;
$alerterr=;
$alertcrit=;

open(FILE, "-|", $curlrun) or die $!;

while (<FILE>) {
  $alertwarn++ if /warn/;
  $alerterr++ if /error/;
  $alertcrit++ if /critical/;
}
close $handle;

$alerttotal=$alertwarn+$alerterr+$alertcrit;

print "warning:" . $alertwarn . "\n";
print "error:" . $alerterr . "\n";
print "critical:" . $alertcrit . "\n";
print "total:" . $alerttotal . "\n";

<?xml version="1.0" encoding="UTF-8" ?>
<feed  version="1.0" hasPendingRequests="false" >
  <company></company>
  <status>200</status>
  <errmsg>OK</errmsg>
  <interval></interval>
    <entry type="predatasource">
        <version>1391573679</version>
        <name>Count Alerts</name>
        <displayedas>_Count Alerts</displayedas>
        <description>Count number of alerts from LogicMonitor.

Gathers warnings, errors, criticals, and a total number.</description>
        <collector>script</collector>
        <hasMultiInstances>false</hasMultiInstances>
        <schedule>600</schedule>
        <appliesTo>system.hostname == &#34;insert-IP-here&#34; or system.hostname == &#34;insert-FQDN-here&#34;</appliesTo>
        <wildcardauto>false</wildcardauto>
        <wildcardpersist>false</wildcardpersist>
        <wildcardlinuxscript></wildcardlinuxscript>
        <wildcardlinuxcmdline></wildcardlinuxcmdline>
        <wildcardwinscript></wildcardwinscript>
        <wildcardwincmdline></wildcardwincmdline>
        <wildcardgroovyscript></wildcardgroovyscript>
        <wildcardschedule>1440</wildcardschedule>
        <wildcarddisable>false</wildcarddisable>
        <agdmethod>none</agdmethod>
        <agdparams></agdparams>
        <group></group>
        <tags></tags>
        <technology></technology>
        <adlist><![CDATA[{"id":0,"agdmethod":"none","params":{},"agdparams":"","filters":[]}]]></adlist>
        <attributes>
        <attribute>
            <name>scripttype</name>
            <value>file</value>
            <comment></comment>
        </attribute>
        <attribute>
            <name>scriptgroovy</name>
            <value>import com.santaba.agent.groovyapi.expect.Expect;
import com.santaba.agent.groovyapi.snmp.Snmp;
import com.santaba.agent.groovyapi.http.*;
import com.santaba.agent.groovyapi.jmx.*;
import org.xbill.DNS.*;</value>
            <comment></comment>
        </attribute>
        <attribute>
            <name>windowsscript</name>
            <value></value>
            <comment></comment>
        </attribute>
        <attribute>
            <name>linuxscript</name>
            <value>/usr/local/logicmonitor/agent/lib/count-alerts.pl</value>
            <comment></comment>
        </attribute>
        <attribute>
            <name>windowscmdline</name>
            <value></value>
            <comment></comment>
        </attribute>
        <attribute>
            <name>linuxcmdline</name>
            <value></value>
            <comment></comment>
        </attribute>
        </attributes>
        <datapoints>
        <datapoint>
            <name>alertwarn</name>
            <dataType>7</dataType>
            <type>2</type>
            <postprocessormethod>namevalue</postprocessormethod>
            <postprocessorparam>warning</postprocessorparam>
            <usevalue>output</usevalue>
            <alertexpr>&#62; 100</alertexpr>
            <alertmissing>1</alertmissing>
            <alertsubject></alertsubject>
            <alertbody></alertbody>
            <description></description>
            <maxvalue></maxvalue>
            <minvalue></minvalue>
            <userparam1></userparam1>
            <userparam2></userparam2>
            <userparam3></userparam3>
            <iscomposite>false</iscomposite>
            <rpn></rpn>
            <alertTransitionIval>2</alertTransitionIval>
            <alertClearTransitionIval></alertClearTransitionIval>
        </datapoint>
        <datapoint>
            <name>alerterror</name>
            <dataType>7</dataType>
            <type>2</type>
            <postprocessormethod>namevalue</postprocessormethod>
            <postprocessorparam>error</postprocessorparam>
            <usevalue>output</usevalue>
            <alertexpr>&#62; 35 50</alertexpr>
            <alertmissing>1</alertmissing>
            <alertsubject></alertsubject>
            <alertbody></alertbody>
            <description></description>
            <maxvalue></maxvalue>
            <minvalue></minvalue>
            <userparam1></userparam1>
            <userparam2></userparam2>
            <userparam3></userparam3>
            <iscomposite>false</iscomposite>
            <rpn></rpn>
            <alertTransitionIval>2</alertTransitionIval>
            <alertClearTransitionIval></alertClearTransitionIval>
        </datapoint>
        <datapoint>
            <name>alertcritical</name>
            <dataType>7</dataType>
            <type>2</type>
            <postprocessormethod>namevalue</postprocessormethod>
            <postprocessorparam>critical</postprocessorparam>
            <usevalue>output</usevalue>
            <alertexpr>&#62; 4 4 5</alertexpr>
            <alertmissing>1</alertmissing>
            <alertsubject></alertsubject>
            <alertbody></alertbody>
            <description></description>
            <maxvalue></maxvalue>
            <minvalue></minvalue>
            <userparam1></userparam1>
            <userparam2></userparam2>
            <userparam3></userparam3>
            <iscomposite>false</iscomposite>
            <rpn></rpn>
            <alertTransitionIval>2</alertTransitionIval>
            <alertClearTransitionIval></alertClearTransitionIval>
        </datapoint>
        <datapoint>
            <name>alerttotal</name>
            <dataType>7</dataType>
            <type>2</type>
            <postprocessormethod>namevalue</postprocessormethod>
            <postprocessorparam>total</postprocessorparam>
            <usevalue>output</usevalue>
            <alertexpr></alertexpr>
            <alertmissing>1</alertmissing>
            <alertsubject></alertsubject>
            <alertbody></alertbody>
            <description></description>
            <maxvalue></maxvalue>
            <minvalue></minvalue>
            <userparam1></userparam1>
            <userparam2></userparam2>
            <userparam3></userparam3>
            <iscomposite>false</iscomposite>
            <rpn></rpn>
            <alertTransitionIval>5</alertTransitionIval>
            <alertClearTransitionIval></alertClearTransitionIval>
        </datapoint>
        </datapoints>
        <graphs>
        <graph>
            <name>Alert Trending</name>
            <title>Alert Trending</title>
            <verticallabel>number</verticallabel>
            <rigid>true</rigid>
            <maxvalue>NaN</maxvalue>
            <minvalue>0.0</minvalue>
            <displayprio>1</displayprio>
            <timescale>1day</timescale>
            <base1024>false</base1024>
            <graphdatapoints>
        <graphdatapoint>
            <name>alertcritical</name>
            <datapointname>alertcritical</datapointname>
            <cf>2</cf>
        </graphdatapoint>
        <graphdatapoint>
            <name>alerterror</name>
            <datapointname>alerterror</datapointname>
            <cf>2</cf>
        </graphdatapoint>
        <graphdatapoint>
            <name>alerttotal</name>
            <datapointname>alerttotal</datapointname>
            <cf>2</cf>
        </graphdatapoint>
        <graphdatapoint>
            <name>alertwarn</name>
            <datapointname>alertwarn</datapointname>
            <cf>2</cf>
        </graphdatapoint>
            </graphdatapoints>
            <graphvirtualdatapoints>
            </graphvirtualdatapoints>
            <graphdatas>
            <graphdata>
                <type>2</type>
                <legend>Total</legend>
                <color>black</color>
                <datapointname>alerttotal</datapointname>
                <isvirtualdatapoint>false</isvirtualdatapoint>
            </graphdata>
            <graphdata>
                <type>1</type>
                <legend>Warnings</legend>
                <color>yellow</color>
                <datapointname>alertwarn</datapointname>
                <isvirtualdatapoint>false</isvirtualdatapoint>
            </graphdata>
            <graphdata>
                <type>1</type>
                <legend>Errors</legend>
                <color>orange</color>
                <datapointname>alerterror</datapointname>
                <isvirtualdatapoint>false</isvirtualdatapoint>
            </graphdata>
            <graphdata>
                <type>1</type>
                <legend>Criticals</legend>
                <color>red</color>
                <datapointname>alertcritical</datapointname>
                <isvirtualdatapoint>false</isvirtualdatapoint>
            </graphdata>
            </graphdatas>
        </graph>
        </graphs>
        <overviewgraphs>
        </overviewgraphs>
    </entry>
</feed>

 

Hi Michael,

thanks for the reply. I was not able to import the XML file, but managed to recreate what you did :-).

Works like a charm, thanks!

Jeroen

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.

Guest
Answer this question...

×   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