R12.1-2025Jul03

Define a Paragraph Parser

A Paragraph Parser extracts essential data from recurring lines of text and displays it in a tabular format. 

Applicable Parser Rules for Paragraph Parser

    When to Use the Paragraph Parser

    A Paragraph Parser converts variables from multiple sections of raw text into a table format, enabling precise diagnosis for each row. 

    Define Paragraph Parser

    To define a paragraph variable, follow the steps below:

    1. Create a new parser,  select the CLI command, enter the command  'show interface ', select the device  BJ-L2-coreB, and retrieve the data.
    2. Select the Paragraph pattern for the new parser. 

    3. Define one or more ID Line Patterns, which will be used as the key to identify recurring paragraphs. The default and mandatory ID Line Pattern, labeled as ID Line A, divides lines of text into paragraphs. Optionally, you can add more ID Line Patterns (B, C, D…) as filters to filter out unqualified paragraphs.
    4. Define Variable Line Patterns to parse variables inside each recurring paragraph identified by ID Line Pattern.
    5. Click Apply to save the parser definitions. 
    6. Click the  icon at the upper-right corner to save the Parser.

    Define a Paragraph Parser for Interface Data

    Use interface information as an example. You can define a Paragraph Parser to extract data from the interface output.

    Follow the steps below to define a paragraph parser for parsing variables based on the sample output of the command (show interface) collected on the device BJ-L2-Core-A:

    1. Create a new parser, then define the parser name (Click the  icon, then change the parser name from "Parser1" to "Interface Info") and the definitions for retrieving CLI command data (set to retrieve CLI Command "show interface" on the device BJ-L2-Core-A). 

    2. Click the Retrieve button to retrieve the sample text. For more information on retrieving command data sources, see Data Source for Retrieving Data in Parser.
    3. Select Paragraph from the Type drop-down menu, then a paragraph pattern will be created.

    4. Parser variables to create ID Line Pattern and Var Line Pattern: Define the paragraph identifier in ID line pattern to identify recurring paragraphs, then define the var line pattern to parser variables in the recurring paragraph. 

      1. In the Parser Input area, double-click "Vlan1", and "up" in line 2 to parser interface variables and interface status data, then an ID Line A containing multi-string variables $var1 and $var2 will be created.
        As you double-click a word in the Parser Input area and the variable is parsed, the searchlight will appear to indicate the matching relationship between the selected text and the parsed variable.

        Information Tip: You can manually add more ID lines by clicking +Field > +ID Line. Otherwise, a new var line will be created if you continue to select a variable in the Parser input area. In this example, we will only add one ID line. 

      2. In the Parser Input area, double-click “1504” in line 4 to parse the MTU variable. A var line1 containing a multi-string variable $int: MTU will be created.  
      3. In the Parser Input area, double-click “0” beside CRC in line 19 to parse the CRC variable. A var line1 containing a multi-string variable $crc will be created.
      4. In the output area, change the variable name and variable type as follows: 

        Change variable name: $var1 -> $interface; $var2 -> $status
        Change variable type: Change the status of $status to mstring.  
    5. Click Apply to confirm the parser definitions. Then check the output for interface information in the output area. The parsed result of a paragraph parser is in a tabular shape. The variables are defined in ID line patterns, variable line patterns.

      Information Note: When you click Apply, the parser UI background will turn blue to indicate that the parser definitions in the current pattern have been confirmed. 
    6. Click the save icon  to save the parser.