Chapter 12. parser: Parse and segment 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 OSE application provides the following possibilities to parse the messages, or parts of the messages:
By default, syslog-ng OSE 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 parse a specially-formatted date or timestamp, see Section 12.6, Parsing dates and timestamps.
To write a custom parser in Python, see Section 12.10, The Python Parser.
To identify and parse the messages using a pattern database, see Chapter 13,
db-parser: Process message content with a pattern database (patterndb).
The syslog-ng OSE application provides built-in parsers for the following application logs:
Apache HTTP server access logs. For details, see Section 12.7, The Apache Access Log Parser.
Cisco devices. For details, see Section 12.8, The Cisco Parser.
Linux Audit (
auditd) logs. For details, see Section 12.9, The Linux Audit Parser.
osquery result logs. For details, see Section 6.8,
osquery: Collect and parse osquery result logs.