Log File Monitor

This agent monitors application log file records. This agent has a dedicated data view board (Log Board) that is specialized in displaying log records.

Local/Remote Modes

The agent can be used both in local and remote modes but the most common use is remote, using the Host Manager on the host where the application log files are located.

Supported Versions

The agent does not have multiple versions defined but it can be used to monitor the log records for any application. There are predefined log record parsers for the following applications:

  • Sun Application Sever 8.x
  • JBoss 4.x
  • WebSphere 5.x and 6.x
  • Weblogic 8.x and 9.x

Configuration

The following parameters are available for configuration:

  • Log file: the path to the application log file on the remote or local host
  • File encoding: the file encoding to use when reading the application log file
  • Available log parsers: choose the type of log parser to use

Log Record Parser Editor

In order to define a log parser for another application click on the 'Edit the list of available log parsers' link in the agent configuration panel to open the dialog which allows you to define a custom log record parser.

The following fields are available:

  • Start of the log record regex: the regular expression used to find the beginning of the log record.
  • End of the log record regex: the regular expression used to find the end of the log record; not required, if left empty the end of the current record will be at the beginning of the next record
  • Log record parser code: the java code used to parse pieces of text between the start and the end of a log record. The java code can be thought of as the body of the only method of the following interface:

/**

* The only method in this interface must be implemented by log parsing scripts.

*/

public interface LogParserScript {

/**

* @param context

* @param lines

* @return

*/

LogRecord parse(LogParserScriptContext context, String[] lines);

}


where LogParserScriptContext is defined by the following interface:


/**

* Interface made available to the log parser scripts. The most common usage

* of this class is to cache objects like DateFormats

* to be available during subsequent invocations of the parser script.

*/

public interface LogParserScriptContext {

/**

* Retrieves an object which was previously registered using the given id.

* @param id

* @return

*/

public Object getScriptData(String id);

/**

* Stores the data object under the given id.

* @param id

* @param data

*/

public void setScriptData(String id, Object data);

}


Note that all classes in the code must be referenced using the fully qualified name as there are no import statements. The following is the definition of the com.ixora.rms.agents.impl.logfile.LogRecord class that must be returned by the parsing code:

                package com.ixora.rms.agents.impl.logfile;

/**

* Holds details about a log record.

*/

public final class LogRecord {

private long fTimestamp;

private long fSequenceNumber;

private String fSeverity;

private String fSourceComponent;

private String fSourceClass;

private String fSourceMethod;

private String fSourceLineNumber;

private String fThread;

private String fMessage;

/**

* @param timestamp the timestamp of the log message

* @param severity the severity level of the log message; it can be null

* @param comp the originating component for the log message; it can be null

* @param clazz the originating Java class for the log message; it can be null

* @param method the originating Java method for the log message; it can be null

* @param line the originating source line for the log message; it can be null

* @param thread the originating thread for the log message; it can be null

* @param seq the sequence number for the log message; it can be null

* @param message the log message

*/

public LogRecord(

long timestamp,

String severity,

String comp,

String clazz,

String method,

String line,

String thread,

long seq,

String message) {

super();

if(timestamp == 0) {

throw new IllegalArgumentException("Invalid timestamp: " + timestamp);

}

if(message == null) {

throw new IllegalArgumentException("Log message is null");

}

this.fTimestamp = timestamp;

this.fSeverity = severity;

this.fSourceComponent = comp;

this.fSourceClass = clazz;

this.fSourceMethod = method;

this.fSourceLineNumber = line;

this.fThread = thread;

this.fMessage = message;

}

/**

* @return the log message

*/

public String getMessage() {

return fMessage;

}

/**

* @return the sequence number for the log file if available

*/

public long getSequenceNumber() {

return fSequenceNumber;

}

/**

* @return the originating Java class if available

*/

public String getSourceClass() {

return fSourceClass;

}

/**

* @return the originating component if available

*/

public String getSourceComponent() {

return fSourceComponent;

}

/**

* @return the originating Java method if available

*/

public String getSourceMethod() {

return fSourceMethod;

}

/**

* @return the originating thread if available

*/

public String getThread() {

return fThread;

}

/**

* @return the timestamp of the log record

*/

public long getTimestamp() {

return fTimestamp;

}

/**

* @return the originating source line number if available

*/

public String getSourceLineNumber() {

return fSourceLineNumber;

}

/**

* @return the severity level for the log message

*/

public String getSeverity() {

return fSeverity;

}

}


Contents

The agent will populate the following values:

Log records: the set of new log records discovered during the last monitoring cycle; when plotting this counter the dedicated 'Log Board' data view board will be used.

Log file size in bytes: the size in bytes of the log file

Last changed timestamp: the timestamp when the log file was last modified

Reactions

The agent has a reaction defined in the 'Log records' data view which is armed and immediatelly fired when the string 'Exeption' is found in any of the log records. In order to change the default 'Exception' string open the data view in the editor and modify the following line: String match="Exception";

Screenshots