Parser

Most recent version: v1.2.0

circle-info

See the changelog of this Action type here.

Overview

The Parser Action can be used to turn raw messages into a map of fields as required. The parser is configured with an expression based on a formal grammar, known as PCL (Parser Configuration Language). Learn more about this language in this article.

If your raw message is a CSV, a JSON, a KVL or an XML, the parser will detect it and will parse the output values accordingly. You can still make changes to get the required output parsing.

circle-exclamation

Ports

These are the input and output ports of this Action:

chevron-rightInput portshashtag
  • Default port - All the events to be processed by this Action enter through this port.

chevron-rightOutput portshashtag
  • Default port - Events are sent through this port if no error occurs while processing them.

  • Error port - Events are sent through this port if an error occurs while processing them.

Configuration

1

Find Parser in the Actions tab (under the Transformation group) and drag it onto the canvas.

2

To open the configuration, click the Action in the canvas and select Configuration.

3

Enter the required parameters:

Select field to parse

First, choose the field to parse from your input data by typing it in the search bar or selecting it from the list.

Input

This is where you specify how to read the incoming data. Choose between:

Parameter
Description

Real data

This is the data taken directly from the linked Listener.

In the Events field at the right part, you can enter how many events to show in this window. You can pause/resume the log loading process or reset the logs shown to show the latest ones by using the icons next to this field.

Paste code

There may be times when you will receive a file with updated data for the Listener. If this is the case, you can paste it here.

Parser

Now that you have specified where to source the data from, you need to determine how to process the events.

By default, the Parser section is displayed in the List view, where you'll see all the resulting fields in a vertical list. You can access the code view of the Parser by clicking the </> icon at the top right corner, where you'll see the results written in the PCL grammar. Learn more about this language and how to modify your messages using it in this article.

Now, choose between Auto and Manual mode. See what happens in each view:

Check what you'll see in the Auto and Manual modes of the parser:

Mode
Description

Auto

Automatically parses all fields from your input message. The parser will detect the structure of the message and will offer you a map of output fields with their corresponding names and types.

You can still modify the delimiters, field names/types, etc. if you need to do some changes. You'll be automatically switched to Manual mode when you do it.

Manual

Manually split fields from your input message and edit them as required. You can perform the following actions by clicking a field name tag:

  • Split fields - Select this option to split a field into several ones. Choose By all delimiters and select/enter the required delimiter to split the whole message as needed. You can also select By delimiter if you only need to split the message once (only the first delimiter in the message will be considered).

  • Extract fields manually - Use this option if you want to extract fields manually. Choose the type of the new field, its name, and the delimiter to be considered. Add as many fields as required and click Save.

  • Extract certain fields - By default, all the parsed fields will be visible in your output message. If you only need to display some of them, you can choose them using this action. Choose the fields you want to display and click Extract fields.

  • Hide fields - You can also hide fields from the output message by clicking the eye icon that appears when you hover over a field. Note that this will only appear if the parser auto detects one of the formats mentioned above (CSV, JSON, KVL or XML).

  • Extract all fields - This option will appear if you've hidden some fields. Use it if you want to display all fields again.

  • Change field types - You can change the type of a field by clicking the field name or checking the box that appears next to it. Click Change type and choose the required data type from the list of available ones. You can change types in bulk selecting all the required field boxes and then choosing the new type for all of them. the option will not be available if there's no type you can convert the field into. Learn more about the different data types in this article.

  • Edit field names - You can edit the name of a field by clicking the pencil icon in its name tag.

  • Ignore delimiters - Choose one or several delimiters and select by checking the boxes that appear next to them and click Ignore delimiters to delete them and join the fields that were separated by them. Remember to rename the resulting group(s) and choose the required data types.

Output

Here you can see the output fields message that will be generated after parsing. Below, each individual field is color-coded according to the legend and separated into its type and name.

You can see the number of new output fields at the top of this box.

4

Click Save to complete the process.

Examples

Select Paste code in the Input area and paste the following logs to see various parsing examples:

Choose Paste code in the Input area and enter the following CSV:

Then, in the Parser area, select Auto to automatically parser this data of the CSV into separate fields. The parser will automatically parse the log, having recognized the comma separators. The default values will be fieldName1.1, fieldName1.2...

Now we have decided which field, from where, and how to parse, we need to specify how it is output to the next Action. Change the names of each field:

  • TIMESTAMP

  • HOSTNAME

  • EVENT_TYPE

  • PROCESS_NAME

  • PROCESS_ID

  • USERNAME

  • IP_ADDRESS

  • HASH

  • THREAT_SCORE

Check if the resulting parsed fields are correct and click Save.

Last updated

Was this helpful?