Collecting application logs
To start collecting logs, you add all the collection-related configurations and other details to a collection policy. You save time by reusing these configurations in multiple collection policies.
The following image shows how logs are collected by using the Linux (RHEL/CentOS) and Windows connectors:
Before you begin
- Make sure that you have downloaded and installed a connector. For more information, see Installing-and-managing-connectors.
- Create a parsing rule. For more information, see Creating-a-parsing-rule .
- Create a filtering rule. For more information, see Creating-a-filtering-rule.
If you plan to filter logs before they are parsed, make sure that you add a separate rule for the pre-filtering process in addition to the filtering process. By prefiltering logs, you limit the number of logs that are parsed and thereby enhance system performance.
To collect application logs
In BMC Helix Log Analytics, use the Collection > Collection Policies > Create button and perform the following steps:
- Add the policy information by performing the following steps:
- Enter a unique name and description.
- From the Connector type list, select the connector type that you have installed.
- Configure the connector by performing the following steps:
- In the Connector Type field, select the connector type that you want to configure.
In Connector Selection Criteria, create the connector selection criteria to identify connectors for collection .
When you click in the box , you are prompted to make a selection. Each time you make a selection, you are progressively prompted to make another selection.
The selection criteria consist of an opening parenthesis, followed by the slot name, the operator, the slot value (which can be a string based on the type of slot selected), and the closing parenthesis. You can optionally select the logical operator AND or OR to add additional conditions. Specifying the opening and closing parentheses is optional.
The connector fields available to create the selection criteria are status, name, version, host_name, ip, and tags.
- Configure log collection by performing the following steps:
- In the Configuration step, click Configure.
In the Log Collection File Path field, enter the path of the log files that you want to collect.
For example: /opt/tomcat/apache.log (Linux) or C:/app1/logs/app.log (Windows).
When you enter folder locations, sub-folders and files present in the folder are shown.- (Optional) If you have entered a path with multiple folders and you want to exclude some folders from collection, in the Exclude Paths field, remove those folders.
For example, you have entered the log collection path as /opt/bmc/connectors/<connector_name>/logs/applicationLogs and this folder contains the following folders: app1, app2, app3. The app1, app2, and app3 folders are shown in the Exclude Paths field. To prevent log collection from the app3 folder, remove the app3 folder from the field. - (Optional) If you want to start collecting logs from the beginning of the file, select the Read Files from Beginning check box.
Else, log collection starts when you enable the policy.
By default, all logs present in a log file are collected. They include the logs that are read for the first time and logs from the last read line. If your log files are created (and rotated) on the basis of time, you have given wildcard (*) in the file path, and the Read Files from Beginning check box is cleared, all logs created after the policy is enabled are collected. - (Optional) Select the Open File on Every Update check box to enable the Open File on Every Update parameter.
When some applications stop updating their log files, the monitoring agents add a permanent read lock to the application log files. To avoid this issue, enable the Open File on Every Update parameter so that the connector opens the log files when they are updated. By default, this parameter is disabled. - Click Save.
- In the Tags field, enter the tags to identify the policy with the collected logs.
The values that you enter in this field are added to the bmc_tags field that is present in the collected logs. You can use the field or tags to search and analyze logs in Explorer. - In Fields, enter the custom information that you want to add to collected logs in the form of key-value pairs.
Use these fields to search and analyze the logs in Explorer. For example, Key: applicationContext; Value: Apache. Use applicationContext:Apache as a search string to search and analyze the collected logs.
(Optional) From the Pre-filtering Rule list, select a filtering rule to help you remove the unwanted log messages before parsing the logs.
If you don't filter the log data before parsing , all the log data will be processed for parsing .- (Optional) From the Parsing Rule 1 list, select a single-line or multiline parsing rule.
If you select a multiline parsing rule, the Parsing Rule 2 list is displayed, where you can select a parsing rule other than multiline parsing rule.
A parsing rule converts raw log data into key-value pairs, making it easy for BMC Helix Log Analytics to search, query, and analyze logs. With multiline parsing rules, you can collect and store multiple lines of log data in a single log entry.
If you have not created a parsing rule, see Creating-a-parsing-rule for instructions. - (Optional) From the Filtering Rule list, select a filtering rule to filter parsed messages.
If you don't filter the logs, all the logs are processed further. If you have not created a filtering rule, see Creating-a-filtering-rule for instructions. - (Optional) From the User group list, select one or more user groups to assign to the collection policy.
Users associated with this user group can see the data collected by this collection policy. If you don't select the user group, log data will be visible to all the users. - Enable and save the policy by performing the following steps:
- To start collecting logs, select the Enable Collection Policy check box.
You can choose to enable the collection policy later. - Click Save .
The created policy is shown on the Collection Policies page. Use the Actions menu to edit, enable (or disable), and delete the policy.
- To start collecting logs, select the Enable Collection Policy check box.
To verify log collection
- Go to BMC Helix Log Analytics and click the Explorer tab.
- Search the logs based on a unique field value.
For example, you can use the tags that you have added to the collection policy. Let's say you added the tag apache_logs. Search for logs by using bmc_tags:apache_logs or applicationContext:Apache.