Define a Collector Parser
For a collector parser, key variables are first defined in the ID line. The collector parser then uses these key variables to identify and group matching variables. The variables are parsed based on the grouping results, and the output is displayed in a table format.
Applicable Parser Rules for Collector Parser
When to Use a Collector Parser
Compared to other types of parsers, the Collector parser offers the following benefits: The Collector parser matches variables by group, and the parsed results are automatically grouped based on the key variable defined in the ID line, allowing for changes in the data arrangement within the parsed results. The Collector Parser is designed for the following common scenarios and more:
- VRRP/IS-IS configuration: Configuration data for VRRP or IS-IS is grouped and can be quickly parsed using the Collector Parser.
- Grouping the log file during the parsing process: When parsing device log file data, the Collector Parser automatically groups the parsed results.
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: The Var line is used for parsing specific variable values in different groups by repeatedly referencing the Key variable defined in the ID line to determine the variable to be parsed. The variable template <% $var %> can be used in the collector parser to assist with variable value definition.
- Variable Template <% $var %> in Collector Parser: When the 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 the 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 pattern "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 the local scope concept, you can select the following rules to define the parse scope of a collector parser.
The following describes the three options in the dialog box:
- 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 parse variables within the scope defined for this collector parser.
- Do not deduplicate the results parsed by ID Line: Repetitive parser results parsed by the 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, follow the steps below:
- 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.

- Double-click parser_test on 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.

- 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.

- 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 a table form. The variables defined in ID line patterns, variable line patterns, and parent line patterns (optional) will be formed as the table columns.
Define a Collector Parser to Parse by the Show Run command
Use the show run CLI command on the Device US-BOS-R1 as an example. You can define a Collector Parser to parse access list and permit information.
- Create a new parser and name it Access List. Then define the settings for collecting CLI command data. In this example, you will retrieve the CLI command data for the "show run" command on the device US-BOS-R1.
- 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.

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

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

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


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 parse the permit data; then, a Variable Line 1 will be created.
- Click Apply to confirm the Var line settings.
- Preview the parsed result of the 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 an interface key if it is an interface-based table, so that you can use this group as an interface data unit in the Data View Template.
- Set as Table Key: Set the variable as a key column variable that will be used in future table comparisons.
- Click the save icon
to save the Collector Parser
Inheriting Table Pattern in Collector Pattern
- Define a table pattern to parse device network configuration, and get variables $interface, $name, $ip_address, $subnet_mask, and $method.

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

- Select the interface pattern as the parent pattern in the collector.
- Use the variable $interface as a variable template in the ID line.
- Define three variables to parse the variables:
- $nameif
- $security_level,
- $address, $mask and $standby.
- Insert scope to limit the parsing scope with the end !. This scope governs the parsing scope of all 3 var lines.
- The final collector output will be shown in the image below:
