SUSE Conversations


Application Monitoring Made Easy for Java Applications – Include / Exclude Filters



By: jarbaby

May 28, 2008 8:03 am

Reads:136

Comments:0

Rating:0

License:
Apache 2.0

download url: http://sourceforge.net/projects/nagiosappender/
home page url: https://sourceforge.net/project/showfiles.php?group_id=140996

In an earlier article (http://www.novell.com/communities/node/4131/application-monitoring-made-easy-java-applications-using-nagios), I presented a simple a method for generating a maintenance free system level view of the status of your backroom applications without the need to refactor any of your code.

The key requirements for this solution are:

  • Java application
  • Log4j logging
  • Nagios monitoring

If your application is like many, though, you may find that there are specific messages you want to ignore … like an ERROR level message that really should have been a DEBUG level. Or perhaps you’re thinking of using Nagios for the first time, and you have a specific error you’re interested in, and can ignore the rest for the time being … By using the log4j facility, in conjunction with the NagiosAppender, we can easily use the existing include / exclude fitler capability to clearly identify the set of messages we want to monitor.

To use filters, first we need to turn the feature on in the NagiosAppender configuration.

log4j.appender.NAGIOS.IncludeFilterEnabled=true
log4j.appender.NAGIOS.ExcludeFilterEnabled=true
log4j.appender.NAGIOS.PatternFilterFile=conf/NagiosIncludeExcludeFilters.properties

or, if you’re using log4.xml

<param name=”IncludeFilterEnabled” value=”true”/>
<param name=”ExcludeFilterEnabled” value=”true”/>
<param name=”PatternFilterFile” value=”conf/NagiosIncludeExcludeFilters.properties”/>

Notice that you can turn include or exclude filters separately.

Now we can turn our attention to the filters file. This file contains a list of regular expressions we are going to use to drive our filter engine. Here is an example of a configuration that passes on all messages, because we’re including everything, and excluding nothing (… not a very useful application of filtering ….)

includeFilter=(.*)
#excludeFilter=(.*)

Note that there are no exclude filters registered. This is important, because if we have enabled both include and exclude filtering, we need to pass both filter tests to pass on the message.

Here is an example of a configuration that has been dialed down to listen for just a few specific message signatures. Again, we are defining regular expressions here, not the actual message. Also, we are matching the regular expression against the unformatted raw log4j message, not the formatted message you’ve defined in your PatternLayout.

includeFilter=New account was just registered for user:(.*)
includeFilter=Account was just deleted for user:(.*)
includeFilter=Bug fix 2738 just failed(.*)
#includeFilter=(.*)
#excludeFilter=(.*)

Quick Review

    Follow instructions for application monitoring (http://www.novell.com/communities/node/4131/application-monitoring-made-easy-java-applications-using-nagios)
    Turn on include and/or exclude filtering in your log4j file as necessary
    Create a properties file that is accessible to your application, and specify it in your log4j file
    Add include and exlude regular expressions to your filters property file

Author

Jarlath Lyons
Senior Software Engineer
Tideworks Technology, Inc.
jarlyons@gmail.com

Technical References

Nagios Server version 2.9
NagiosAppender version 1.2.4
Log4j version 1.2.9

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)


Categories: Free Tools, Technical Solutions

Comment

RSS