Description
For monitoring purposes, you may want to extract string or numeric values from a multi-line file. Because this action is not possible per se, you will have to first transform your file into a single-line file and then extract the required values.
The features to use in Monitoring Studio are:
- The Text Pre-Processing feature
- The Numeric Value Extraction feature.
Procedure
In the example below, we will transform the following multi-line file into a single-line file:
<rate  name="inj_recips"
  last_1_min="20486"
  last_5_min="20401"
  last_15_min="16601"  />
and extract the value for last_5_min.
Step 1: Transforming Data into a Single-Line Record
- In the PATROL Console, right-click the File instance and select KM Commands > New > Text Preprocessing...
- Select Convert multi-line records into single lines.
  
- Click Next to continue.
- Configure the Text Pre-Processing feature:
    - In the field This RegExp marks the beginning of the new record, enter <rate name=”inj_recips”
- Check the option Include the first line in the result
- In the field This RegExp marks the end of a record, enter />
- Set  ‘;’ as a line separator
  
 
- Click Next to continue.
- Provide an Object display name and click Finish. 
  
- The TransformResult file is then created in the tree view:
  
 and contains one single-line:
  
Step 2: Extracting a Numeric Value
In the procedure below, we will extract the numeric value of the “last_5_min” parameter.
- In the PATROL Console, right-click  the Text Pre-Processing instance and  select New > Numeric Value Extraction
  
- Click Next to continue.
- From the Extract numeric values from drop-down list, select Lines matching the regular expression below.
- Enter the first RegEx marking the  beginning of the record. In our example, <rate  name=”inj_recips”.
  
- Click Next to continue.
- From the drop-down list, select after the string, type last_5min=”.
  
- Click Next to continue.
- From the drop-down list, select the  computation option keep the last value  found.
  
- Click Next to continue.
- Check the Value option as the parameter to collect.
  
- Click Next to continue.
- Provide an Object display name and click Finish.
  
- The Value parameter is then created under the inj_recips_last_5_min   instance:
  
 
Related Topics
- Log File Monitoring: Searching for a String and Triggering Alarm for each Occurrence
- Monitoring Studio: Monitoring Remote Log/Flat Files
- Monitoring Studio: Increasing Maximum File Size Limit
- Monitoring Studio: File Monitoring on Dynamic Files
- Monitoring Studio: Getting Automatically Notified by Email for an Error in a Log File

