Parser-combinator (Parsec)¶
A parser-combinator technique is used for parsing events in plain string format. It is based on SP-Lang Parsec expressions.
For parsing original events, use the following declaration:
define:
name: My Parser
type: parsec/parser
parse:
!PARSE.KVLIST
- ...
- ...
- ...
define:
name: My Parser
type: parsec/parser
field: <custom_field>
parse:
!PARSE.KVLIST
- ...
- ...
- ...
When field is specified, parsing is applied on that field, otherwise it is applied on the original event. Therefore, it must be present in every sub-parser.
Types of field specification:
-
field: <custom_field>- regular field pre-parsed by the previous parser. -
field: json /key/foo- JSON key/key/foofrom pre-parsed JSON objectjson. Name of the JSON object and JSON key must be separated by space. JSON key always starts with/, and every next level is separated by/. -
JSON key with specified type, by default we assume
stringtype.field: json: /key/foo type: int -
field: xml /key/foo/@attribute- XML key/key/foo/@attributefrom pre-parsed XML objectxml. Name of the XML object and XML key must be separated by space. XML key always starts with/, and every next level is separated by/. The class attribute is denoted by@.