Monitoring

JBoss Alarm configuration

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="org.jboss.monitor.services.ActiveAlarmTable"
          name="jboss.monitor:service=ActiveAlarmTable">
      <attribute name="SubscriptionList">
         <subscription-list>
            <mbean name="jboss.monitor:*">
               <notification type="jboss.alarm"></notification>
               <notification type="JBOSS_MONITOR_NOTIFICATION"></notification>               
            </mbean>
            <mbean name="jboss.system:service=Logging,type=JMXNotificationAppender"></mbean>
         </subscription-list>
      </attribute>
   </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="org.jboss.monitor.services.MemoryMonitor"
         name="jboss.monitor:service=MemoryMonitor">
         
    <attribute name="FreeMemoryWarningThreshold">95M</attribute>
    <attribute name="FreeMemoryCriticalThreshold">80M</attribute>    
  </mbean>
ù

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="org.jboss.monitor.services.JMXNotificationAppender">
      <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"/>
      </layout>
   </appender>

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

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

Related articles available on mastertheboss.com

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:

Follow us on Twitter