R12.1-JA-2025June05

Define a Collector Parser

For collector parser, key variables are defined in the ID line in the first place. Then, a Collector Parser will find matched variables by the key variables and group the variables by the key variables, parsing those variables based on the grouping results. The parsed results are in table format. 

Applicable Parser Rules for Collector Parser

When to Use a Collector Parser

Compared with other types of parsers, collector parser has the following benefits: Collector parser will match variable by group, the parsed results are automatically grouped based on the key variable defined in ID line, which can change the data arrangement in the parsed results. The Collector Parser is designed for the following typical scenarios and more:

  • VRRP/IS-IS configuration: The data of VRRP/IS-IS configuration is in group, which can be quickly parsed by collector parser. 
  • Grouping log file during the parsing process: When parsing device log file data with collector parser, the parsed results can be automatically grouped. 

Line Patterns and Logics for Collector Parser

  • ID Line in Collector Parser: The ID line pattern holds the ID variable (key variable) in the variable group, only the pattern for parsing ID variables is defined here. The parser inputs will be grouped by the actual value of the ID variable.   
  • Var Line in Collector Parser: Var line is for parsing specific variable values in different groups by repetitively referencing the Key variable defined in the ID line to determine the variable to be parsed. Variable Template <% $var %> can be used in collector parser to help the variable value definition.
  • Variable Template <% $var %> in Collector Parser: When variable template is used, the variable in the var line is not defined in the form of $ var. Instead, the variable in a var line is replaced with corresponding string type variable based on the ID variable value of the current group. The Var line pattern with the variable template will match the input text. For example, if we define the line patten "vrrp <%$vrrp_num%> address-family $address_family" for parsing the address family data for all vrrp, the variable template <%$vrrp_num%> means the system will parse matched values in this Var line in every group decided by the vrrp_num value. For more information about variable template, see Declare Variables/Variable Template <% $var %>

Advanced Settings in Collector Pattern

With the introduction of local scope concept, the following rules can be selected to affect the parse scope of a collector parser.

The meanings of the three options are listed below:

  • Do not inherit scope of parent pattern: If the collector parser inherits another parser rule (parent pattern), the scope in that parent pattern will not be used. Instead, the collector parser will parser variable within the scope defined for this collector parser.
  • Do not deduplicate the results parsed by ID Line: The repetitive parser results parsed by ID Line will not be removed.
  • Variable line uses Whole Command Text scope by default: The var lines will use the whole command text as the scope rather than the scope defined for this collector parser.

Define a Collector Parser by Example

To define a collector parser, you need two main steps:

  1. Double-click 1 in line 134 to parse the variable $int: vrrp, then an ID Line is created, which will be used as the keyword to identify recurring groups. If you want to define an optional Parent Line, please refer to Parent Line for more details.

  2. Double -click 'parser_test' in line 134 to create Variable Line Pattern 1, then insert the variable template in the variable line pattern to parse variable $des inside each recurring group identified by ID Line Pattern.
  3. Double-click '10.1.1.254' in line 135 to create variable line pattern 2 parse the then insert the variable template in the variable line pattern to parse variable $ip inside each recurring group identified by ID Line Pattern.

  4. Check the output table and save the parser. The final output table will be shown below.

The parsed result of a Collector Parser is in table form. The variables defined in ID line patterns, variable line patterns, and parent line patterns (optional) will be formed as table columns.

Define a Collector Parser to Parse by the Show Run command

Take CLI commands of "show run" of the Device US-BOS-R1 as an example. You can define a Collector Parser to parse access list and permit information.

  1. Create a new parser and name it "Access List". Then define the settings for collecting CLI command data. In this example, we will retrieve the CLI command data of "show run" on the device US-BOS-R1
     
  2. Click the Retrieve button to retrieve the sample text. For more information about the sources for retrieving command data, see Data Source for Retrieving Data in Parser.

  1. Click + New Pattern > Advanced > Collector to select the collector parser type, then a collector pattern with an empty ID line will be created.

  2. Define ID Line Pattern: Click 1 in line 440 to identify the recurring groups. The variable $int: access_list is parsed and command line containing this variable will be added to the ID line. 

  3. Click Apply to confirm the ID line definition.
  4. Define Variable Line Pattern: parsing variables inside each recurring groups that has been identified by ID Line Pattern.

    Information Note: If you continue to add variables, the existing line pattern and output will be disabled and cannot be modified. The new pattern and output (in red background) temporarily created by adding variables can be edited.
    • Select 10.8.0.0/16 in the Sample area to parser the permit data, then a Variable Line 1 will be created.  
  5. Click the Apply button to confirm the Var line settings. 
  6. Preview the parsed result of sample text.

    In the output pane, you can make further settings from the column menu of the result table:

    • Set as Interface Key: Set the variable as interface key if it is an interface-based table so that you can use this group as interface data unit in Data View Template.
    • Set as Table Key: Set the variable as key column variables that will be used in future table comparison. 
  7. Click the save icon  to save the Collector Parser 

Inheriting Table Pattern in Collector Pattern

In some cases, a table pattern and a collector pattern are related to one another. Variable can be used as variable template <%$var%> in the line patterns of the Collector pattern so that collector parser can inherit the values of another table parser.
Example: Variable $interface is parsed in Table 1, then $interface is converted to a variable template to be used in the ID Line of Collector 1. In this way, Collector 1 inherits the table pattern.
  1. Define a table pattern to parse device network configuration, and get variables $interface, $name, $ip_address, $subnet_mask, and $method.

  2. Define a collector pattern, select table pattern as its parent. The variables in the table pattern can be used in the collector pattern.

    • Select interface pattern as the parent pattern in collector.
    • Use the variable $interface as variable template in the ID line.
    • Define 3 var lines to parse variables $nameif, $security_level, $address, $mask and $standby.
    • Insert scope to limit the parsing scope with the end !. This scope govern the parsing scope of all 3 var lines.
  3. The final collector output is like below: