Configuring an adapter for live application monitoring

The Generic Log Adapter provides an outputter class that allows the Common Base Event objects generated by your adapter to be sent to a logging agent. The Log and Trace Analyzer can be used to attach to the logging agent, to monitor and to analyze the application log in real time.

Prerequisites:

Follow these steps to configure your adapter for monitoring.

Configure the Outputter component

Note: When a new adapter configuration file is created, it is configured to use the CBELogOutputter class by default. If you have not changed this setting, you can skip this procedure.

The outputter component in the adapter configuration file needs to be updated to use the CBELogOutputter class which writes the Common Base Event objects to a logging agent. You can either update the existing Outputter Component or add a new Outputter component.

To add a new outputter component:

  1. To edit the adapter configuration file, select the adapter configuration file in the Navigator pane. Right-click and select Open with > Adapter Configuration Editor. The file is opened in the editor.
  2. In the Adapter Configuration Editor window, expand the Adapter > Configuration > Context Instance node.
  3. Right-click on the Context Instance and select Add > Outputter. A new outputter is created in the Context Instance.
  4. In the Outputter Type field, select LoggingAgentOutputter.
  5. Click on the agentName property. The property details are shown in the right pane.
  6. Update the property value with the desired logging agent name. This is the name that you will see in the Log and Trace Analyzer as the Logging Agent to monitor.
  7. If you want the outputter to wait before writing the Common Base Events to the logging agent, add a property called waitUntilLoggingTime and set the value of the property to the time in milliseconds. To add the property, right-click on the newly created Outputter and select Add > Property. A new property is created under the new Outputter node.
  8. To enable the CBELogOutputter class, you need to create the associated Outputter component in the Contexts Basic Context Implementation. Open Contexts > Context Basic Implementation Context.
  9. Right-click on Context Basic Implementation Context and select Add > Component. A new component is added to the context.
  10. Configure the new component with the following values:
    Name: Outputter name in the context
    Description: Description of what this outputter does
    Executable class: org.eclipse.hyades.logging.adapter.outputters.CBELogOutputter
    Logging level:The level of internal logging the outputter component should use.
    A value of 99 means the outputter will not log any messages.
    A value of 0 means the outputter will log messages of all severities.
    The recommended value is 50 which means that only Critical or Fatal internal outputter errors messages are logged.
    Role: Outputter
    UniqueID: Must point to the outputter defined in the Context Instance in step 3. Use the Browse button to select the correct ID.
  11. Save the adapter configuration file changes.

Configure the context instance

If you want the log parser to monitor the log file continuously, you need to update the context instance properties of the adapter configuration file for continuous operation.

  1. To edit the adapter configuration file, select the adapter configuration file in the Navigator perspective. Right-click and select Open with > Adapter Configuration Editor. The file is opened in the editor.
  2. In the editor window, select Adapter > Configuration > Context Instance . The Context Instance details are displayed in the right pane.
  3. Select the Continuous Operation check box.
  4. Configure the Maximum Idle Time and Pause Interval fields as required.
  5. Save the adapter configuration file changes.

Launch a Java process to run the adapter

The log adapter you created can be run externally from a batch file in the Windows environment or a shell script in non-Windows environments. Below are sample files that can be used to launch the Java process that will run your log adapter.
Note: To attach and monitor the logging agent created by the Generic Log Adapter, a Hyades Agent Controller must be installed on the system where Generic Log Adapter is to run and it must be started before Generic Log Adapter is started.

Windows batch file:

@rem USAGE: runregex 
@rem PURPOSE: Illustrates the functional capabilities of the Generic Log Adapter (GLA) 
@rem run-time using an example adapter file and sample log file. 
@rem ASSUMPTIONS: This batch file assumes the GLA run-time and required files are 
@rem stored in the following directory structure: 
@rem %GLA_HOME%\config - GLA adapter configuration files 
@rem %GLA_HOME%\lib - GLA run-time and required jars 
@rem %GLA_HOME%\schema - GLA adapter configuration schema files 
@rem INSTRUCTIONS: 
@rem If the GLA run-time and required files are stored as indicated in the 
@rem assumptions section above, change the value of the %GLA_HOME% 
@rem environment variable to the absolute path where the GLA run-time 
@rem and required files are stored. 
@rem If the GLA run-time files are stored in a plug-in (e.g. Eclipse) 
@rem environment, perform the following instructions: 
@rem 1) Create a temporary directory to store the GLA run-time and required files. 
@rem 2) Create the config, lib, and schema directories in the temporary 
@rem directory creatd in step 1) 
@rem 3) Change the value of the %GLA_HOME% environment variable to the 
@rem absolute path of the temporary directory created in step 1) 
@rem 4) Copy the adapter files you want to run into the %GLA_HOME%\config directory. 
@rem For example if you want to run the Apache adapter files then copy the 
@rem Apache directory of the org.eclipse.hyades.logging.adapter.config 
@rem plug-in and all of its contents to the %GLA_HOME%\config directory. 
@rem 5) Copy the contents of the schema directory of 
@rem org.eclipse.hyades.logging.adapter plug-in to the %GLA_HOME%\schema directory. 
@rem 6) Copy the following jar files to the %GLA_HOME%\lib directory 
@rem Plug-in | JAR 
@rem --------------------------------------------------- 
@rem org.eclipse.hyades.logging.adapter | hgla.jar 
@rem org.eclipse.hyades.logging.core | hlcbe101.jar 
@rem org.eclipse.hyades.logging.core | hlcore.jar 
@rem org.eclipse.hyades.execution.remote | hexr.jar 
@rem org.eclipse.emf.ecore | ecore.jar 
@rem org.eclipse.emf.common | common.jar 

SET GLA_HOME=d:\GenericLogAdapter 
SET CONFIG_FILE=%GLA_HOME%\config\my.adapter 
@PUSHD %GLA_HOME%\config\ 
java -DGLA_HOME="%GLA_HOME%" -classpath "%GLA_HOME%\lib\hgla.jar;%GLA_HOME%\lib\hexr.jar;%GLA_HOME%\lib\hlcbe101.jar;%GLA_HOME%\lib\ecore.jar;%GLA_HOME%\lib\common.jar;%GLA_HOME%\lib\hlcore.jar" org.eclipse.hyades.logging.adapter.Adapter -ac "%CONFIG_FILE%" -cc "%CONFIG_FILE%" 
POPD


non-Windows batch file:
#!/bin/sh 
# USAGE: runregex.sh 
# PURPOSE: Illustrates the functional capabilities of the Generic Log Adapter (GLA) 
# run-time using an example adapter file and sample log file. 
# ASSUMPTIONS: This shell file assumes the GLA run-time and required files are 
# stored in the following directory structure: 
# %GLA_HOME%/config - GLA adapter configuration files 
# %GLA_HOME%/lib - GLA run-time and required jars 
# %GLA_HOME%/schema - GLA adapter configuration schema files 
# INSTRUCTIONS: 
# If the GLA run-time and required files are stored as indicated in the 
# assumptions section above, change the value of the %GLA_HOME% 
# environment variable to the absolute path where the GLA run-time 
# and required files are stored. 
# If the GLA run-time files are stored in a plug-in (e.g. Eclipse) 
# environment, perform the following instructions: 
# 1) Create a temporary directory to store the GLA run-time and required files. 
# 2) Create the config, lib, and schema directories in the temporary 
# directory creatd in step 1) 
# 3) Change the value of the %GLA_HOME% environment variable to the 
# absolute path of the temporary directory created in step 1) 
# 4) Copy the adapter files you want to run to the %GLA_HOME%/config directory. 
# For example, if you want to run the Apache adapter files then copy the 
# Apache directory of the org.eclipse.hyades.logging.adapter.config 
# plug-in and all of its contents to the %GLA_HOME%/config directory. 
# 5) Copy the contents of the schema directory of 
# org.eclipse.hyades.logging.adapter plug-in to the %GLA_HOME%/schema directory. 
# 6) Copy the following jar files to the %GLA_HOME%/lib directory 
# Plug-in | JAR 
# --------------------------------------------------- 
# org.eclipse.hyades.logging.adapter | hgla.jar 
# org.eclipse.hyades.logging.core | hlcbe101.jar 
# org.eclipse.hyades.logging.core | hlcore.jar 
# org.eclipse.hyades.execution.remote | hexr.jar 
# org.eclipse.emf.ecore | ecore.jar 
# org.eclipse.emf.common | common.jar 

GLA_HOME=/home/eclipse/GenericLogAdapter 
export GLA_HOME 

CONFIG_FILE="$GLA_HOME/config/my.adapter" 
export CONFIG_FILE 

CUR_DIR=`pwd` 
export CUR_DIR 

cd "$GLA_HOME/config" 

java -DGLA_HOME="$GLA_HOME" -classpath "$GLA_HOME/lib/hgla.jar:$GLA_HOME/lib/hexr.jar:$GLA_HOME/lib/hlcbe101.jar:$GLA_HOME/lib/ecore.jar:$GLA_HOME/lib/common.jar:$GLA_HOME/lib/hlcore.jar" org.eclipse.hyades.logging.adapter.Adapter -ac "$CONFIG_FILE" -cc "$CONFIG_FILE" 

cd "$CUR_DIR"
Configure the file as required to launch the Java process that will run your adapter.

Monitoring the live application log

You are now ready to monitor the live application log.

  1. Ensure that logging is enabled in the preferences.
    1. From the main toolbar, select Window > Preferences . The Preferences wizard opens.
    2. Select Profiling and Logging from the left pane. The Profiling and Logging preferences are loaded in the right pane.
    3. Select Enable logging under Profiling and Logging options.

      Enable logging check box is selected in the preferences pane for Profiling and Logging

    4. Select OK to apply the changes.
  2. In the Profiling and Logging perspective, click Profiling Icon of profiling tool the toolbar and select Profile. The Profile wizard opens.
  3. Select Attach - Java Process and click the New button at the bottom of the list. A new Java process configuration is created.
  4. Click the Hosts tab and select the host on which the application log resides.
    Note: To monitor a live application log, Agent Controller must be running on the same system as the application.
  5. Click the Agents tab and use the arrow keys to select the logging agent that you configured.

    In the profiling preferences wizard, the logging agent the user created is on the left pane

  6. Click Apply.
  7. Click Profile to attach to the Logging agent.
  8. In the Profiling and Logging perspective in the Profiling Monitor view, select the logging agent.
  9. Right-click on the agent and select Start monitoring.
  10. Right-click on the agent and select Open with > Log View. The log events from the application log are loaded into the Log view.
    Note: If you do not see any log records in the Log View, click on the Refresh Views button at the top of the Profiling Monitor pane.

 

Related Concepts
Overview of the Generic Log Adapter
Common Base Event format specification

Related tasks
Creating a log parser

Related references
Adapter Configuration File structure
Adapter Configuration Editor
Regular expression grammar