An Alarm indicates that an event (generally an error) has happened in the system. In this article we're going to show how you can activate alarms to keep track of these error conditions.

Looking for error in the console log is usually cumbersome because the log contains quite a lot of information. You might be interested to isolate only a few conditions like a Memory Threshold or a Deployment error.

JBoss keeps track of Alarm in a Table called the Active Alarmtable. By default this table is disable, you have to activate it through the conf/jboss-service.xml file. Enable the following MBean (about at line 121)

  <mbean code=""
      <attribute name="SubscriptionList">
            <mbean name="jboss.monitor:*">
               <notification type="jboss.alarm"></notification>
               <notification type="JBOSS_MONITOR_NOTIFICATION"></notification>               
            <mbean name="jboss.system:service=Logging,type=JMXNotificationAppender"></mbean>

Now restart jBoss and verify from the Web Console that the Alarm Table appears in the options (In the Monitoring Menu) :

Adding a Memory monitor

One useful alarm notification could be a Memory monitor. If you want to send an alarm when certain memory thresholds are crossed, then uncomment the following MBean in deploy/monitoring-service.xml

 <mbean code=""
    <attribute name="FreeMemoryWarningThreshold">95M</attribute>
    <attribute name="FreeMemoryCriticalThreshold">80M</attribute>    

Set up a threshold near to your Server free memory and verify from the Web Console that the alarm has been emitted: 

jboss alert

Capturing Logging events as alarms

You can as well have your Log4j emit logs as JMX events. This can be achieved by uncommenting the JMX appender (in conf/jboss-log4j.xml):

   <appender name="JMX" class="">
      <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
      <param name="Threshold" value="WARN"/>
      <param name="ObjectName" value="jboss.system:service=Logging,type=JMXNotificationAppender"/>
      <layout class="org.apache.log4j.PatternLayout">
         <param name="ConversionPattern" value="%d %-5p [%c] %m"/>

And remeber to add the appender-ref to the Root appender (at the bottom of log4j file)

      <appender-ref ref="CONSOLE"/>
      <appender-ref ref="FILE"/>
      <appender-ref ref="JMX"/>


Related articles available on

How to monitor JBoss CPU usage ?

  JBoss AS 7 users and WildFly can use JConsole in order to moni

How to monitor jboss graphically ?

  You’ve been using the JMX Console to access yourMBeans. In thi

How to monitor JBoss with snapshots?

  JBoss gives you the ability to capture data not only in real t

Monitoring JBoss EJB Container

In this article we will show how easily you can write an Intercep

Monitor JBoss AS with Jolokia

Jolokia is a cool monitoring solution for accessing JMX MBeans re

How to solve java.lang.OutOfMemoryError: unable to create new nat

In Java you can stumble upon two kind of Out of Memory errors: