Log Analysis APIs
The log analysis service provides a set of APIs to analyze a list of common base events against a list of symptom catalogs. The following workflow shows the steps to analyze a list of common base events.
-
Create an analysis facade.
-
Register a list of symptom catalogs.
-
Create a context object that will contain information needed by the analysis operation.
-
Create list of rules for the analysis operation.
-
Select an analysis operation from a list of registered analysis operations.
-
Analyze the log agent against the list of rules.
-
Check the context status to determine if the analysis operation was successful.
The following code snippet illustrates this workflow and demonstrates how to analyze a list of common base events against a set of symptom catalogs.
1
|
IAnalysisFacade analysisFacade = AnalysisFacadeFactoryWrapper.instance(); |
2
|
String[] sympDbs = new String[1];
sympDbs[0] = "file://D:/myWorkSpace/sdb/test.symptom";
analysisFacade.registerSymptomDatabases(sympDbs);
|
3
|
ICorrelationOperationContext context = analysisFacade.createOperationContext(); |
4
|
List rules = analysisFacade.createRulesList(context); |
5
|
List operations = analysisFacade.getRegisteredAnalysisOperations(context);
IBaseAnalysisOperation xpathOperation = (IBaseAnalysisOperation)operations.get(0);
|
6
|
context.setProperty(XPathCorrelationEngine.STATELOCATION, "D:\\myWorkSpace\\temp");
List result = new ArrayList();
analysisFacade.analyzeLog(xpathOperation, getEvents(), rules, result, context);
|
7
|
if (context.getStatus().isOK())
System.out.println("Analysis successful!"); |
1. Create an analysis facade
IAnalysisFacade provides all the necessary APIs to perform an analysis operation. The following factory method should be used to create the IAnalysisFacade instance.
AnalysisFacadeFactoryWrapper.instance()
2. Register a list of symptom catalogs
Before analyze a log a set of symptom catalogs must be registered with the facade. The registered catalogs will be used to construct a list of symptom rules that will be used to analyze the list of common base event. The following IAnalysisFacade API takes in a list of paths that specifies the location of the symptom catalogs.
public void registerSymptomDatabases(String[] symptomdbPath)
The IAnalysisFacade also provides APIs to de-register the symptom catalog.
3. Create a context object that will contain information needed by the analysis operation
Each analysis operation may require specific configuration information to complete the operation. Specific configuration information is passed to the analysis operation via the context object. One should consult the java doc for each analysis operation to determine the configuration information needed.
4. Create list of rules for the analysis operation
Once the list of symptom catalogs are registered the rules used for analysis can be created. The following IAnalysisFacade API should be used to create the rule list.
public List createRulesList(IOperationContext context)
5. Select an analysis operation from a list of registered analysis operations
A list of analysis operations can be registered with the service. The following extension point can be used to register analysis operations.
- org.eclipse.hyades.analysis.engine.logAnalyzer
There is a corresponding ICorrelationFacade APIs to get a list of registered analysis operations from the above extension point.
public List getRegisteredAnalysisOperations(IOperationContext context)
A particular analysis operation should be selected from the returned lists.
6. Analyze the log agent against the list of rules
The next step is to analyze the list of common base events using the following API.
public void analyzeLog(IBaseAnalysisOperation operation, List events, List rules, List result, ICorrelationOperationContext context)
This API. takes in the selected analysis operation, the list of common base event to analyze, the list of symptom rules and a context object that contains configuration information needed by the analysis operation. Note in the above example it sets a temporary directory to store the transient data of the analysis operation. In this case the XPath analysis engine requires a cache directory to save temporary data.
7. Check the context status to determine if the analysis operation was successful
Once the analysis has completed status information should be checked to make sure the analysis operation was successful. The status information is stored in a org.eclipse.tptp.platform.provisional.correlation.common.IOperationStatus instance which can be extracted from the context object.
Related concepts
Determining problems in distributed applications using the Log and Trace Analyzer
Log file correlation