Chapter 12. Parsers and segmenting structured messages
The filters and default macros of syslog-ng work well on the headers and metainformation of the log messages, but are rather limited when processing the content of the messages. Parsers can segment the content of the messages into name-value pairs, and these names can be used as user-defined macros. Subsequent filtering or other type of processing of the message can use these custom macros to refer to parts of the message. Parsers are global objects most often used together with filters and rewrite rules.
The syslog-ng PE application provides the following possibilities to parse the messages, or parts of the messages:
By default, syslog-ng PE parses every message as a syslog message. To disable message parsing, use the
flags(no-parse)option of the source. To explicitly parse a message as a syslog message, use the
syslogparser. For details, see Section 12.1, Parsing syslog messages.
To segment a message into columns using a CSV-parser, see Section 12.2, Parsing messages with comma-separated and similar values.
To segment a message consisting of whitespace or comma-separated
key=valuepairs (for example, Postfix log messages), see Section 12.3, Parsing
To parse JSON-formatted messages, see Section 12.4, The JSON parser.
To parse XML-formatted messages, see Section 12.5, The XML parser.
To identify and parse the messages using a pattern database, see Chapter 13, Processing message content with a pattern database.
To parse a specially-formatted date or timestamp, see Section 12.6, Parsing dates and timestamps.
To write a custom parser in Python or Hy, see Section 12.8, The Python Parser.
The syslog-ng PE application provides built-in parsers for the following application logs:
Cisco devices. For details, see Section 12.7, The Cisco Parser.