The syslog-ng application can separate parts of log messages (i.e., the contents of the $MSG macro) to named fields (columns). These fields act as user-defined macros that can be referenced in message templates, file- and tablenames, etc.
To create a parser, define the columns of the message, the delimiter or separator characters, and optionally the characters that are used to escape the delimiter characters (quote-pairs).
Declaration:
parser parser_name {
csv-parser(column1, column2, ...)
delimiters()
quote-pairs()
};
Column names work like macros. Always use a prefix to identify the columns of the
parsers, e.g., MYPARSER1.COLUMN1, MYPARSER2.COLUMN2, etc. Column
names starting with a dot (e.g., .HOST) are reserved for use by
syslog-ng.
| Name | Synopsis | Description |
|---|---|---|
| csv-parser | csv-parser(columns("PARSER.COLUMN1", "PARSER.COLUMN2", ...)) | Specifies the type of parser to use, and the name of the columns to
separate messages to. Currently only the
csv-parser is implemented, which can separate
columns based on delimiter characters and strings. |
| delimiters | delimiters("<delimiter_characters>") | The character that separates the columns in the message. |
| flags() | flags(escape-none,escape-backslash,escape-double-char,strip-whitespace ) | Escaping rules used by the parser. The
strip-whitespace flag removes trailing
whitespaces from the beginning and the end of the columns. |
| quote-pairs() | quote-pairs('<quote_pairs>') | List quote-pairs between single quotes. Delimiter characters enclosed
between quote characters are ignored. Note that the beginning and ending
quote character does not have to be identical, e.g.,
[} can also be a quote-pair. |
| template() | template("${<macroname>}") | The macro that contains the part of the message that the parser will process. It can also be a macro created by a previous parser of the log path. By default, this is empty and the parser processes the entire message. |
Table 8.20. Parser parameters
© 2007-2008 BalaBit IT Security
Please send your comments or documentation bugs to: documentation@balabit.com