Developing a custom parser module

Use the Integration Studio to develop and work with custom parser modules.

A parser is a class that extends the Parser class in TrueSight Capacity Optimization. For the parser to produce data, you need to implement the abstract parse method. For more information, see the following sections:

About the abstract parse method

 After you implement the abstract parse method, the parser receives the full name (of the file to parse) as the first parameter and returns a DataSetList object containing data that has been extracted.

Note

The parser does not find and select files to parse. The ETL framework does this task in advance as per the configuration present during the creation of the ETL.

For example: The ETL is configured to access a Secure File Transfer Protocol (SFTP) folder and select files that match a certain pattern. The ETL framework will copy the selected files via SFTP to the local ETL engine disk and then, it will sequentially call the parse method of the defined custom parser for each file. This means that the ETL will:

  1. Call the parse method for the first file.
  2. Populate the output dataset with the result.
  3. Call the parse method for the second file.
  4. Append the result to the dataset, and so on.
    After parsing each file and depending on configuration, the ETL framework will rename or move the parsed file.

Consider the following example:

Example

You need to extract the CPU Utilization metric from a text file in the following format:

2011-07-07/CPU:15.2,13,25,15,13,25,15.1,13,25.1,15.1,13,25,15,13,25
2011-07-07/DISK:1,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1
2011-07-08/CPU:15,13,25,15,13,25,15,13,25,15,13,25,15,13,25,15,13,25
2011-07-08/DISK:1,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1
.. ..
..

The contents of this file are not columnar; each row has different metrics and contains hourly samples from a 24-hour day. To parse a file in this format, you will need to utilize a custom parser.

Full example code

Here you can download the full code of the example presented: MyParserP.pm.

To develop a custom parser module

  1. Creating a custom parser module
  2. Editing parser code
  3. Activating a custom parser module
  4. (Optional) To store your ETL code in a secure location and share the code, see Saving a copy of an Integration Studio project.
  5. (Optional) To debug the custom parser module, see Debugging a custom parser or extractor module.

Where to go from here

Creating a custom parser module

Was this page helpful? Yes No Submitting... Thank you

Comments