Set the severity field
It is possible to configure the severity field with the set-severity() rewrite function. When configured, the set-severity() rewrite function will only rewrite the $SEVERITY field in the message to the first parameter value specified in the function.
FilterX has no set_severity() counterpart. See the related set_pri() function, which sets the combined PRI value (facility * 8 + severity), so you cannot set the severity without also setting the facility. It also takes a number, not a severity name.
Declaration
rewrite <name_of_the_rule> {
set-severity("severity string or number");
};
Parameters
The set-severity() rewrite function has a single, mandatory parameter that can be defined as follows:
set-severity( "parameter1" );
Accepted values
The set-severity() rewrite function accepts numeric values, named values, and aliases. Aliases are available in AxoSyslog version 4.6 and later.
| Numerical Code | Named Value | Alias |
|---|---|---|
| 0 | emerg |
SYSLOG_SEVERITY_CODE(0) |
| 0 | emergency |
SYSLOG_SEVERITY_CODE(0) |
| 0 | panic |
SYSLOG_SEVERITY_CODE(0) |
| 1 | alert |
SYSLOG_SEVERITY_CODE(1) |
| 2 | crit |
SYSLOG_SEVERITY_CODE(2) |
| 2 | critical |
SYSLOG_SEVERITY_CODE(2) |
| 2 | fatal |
SYSLOG_SEVERITY_CODE(2) |
| 3 | err |
SYSLOG_SEVERITY_CODE(3) |
| 3 | error |
SYSLOG_SEVERITY_CODE(3) |
| 4 | warning |
SYSLOG_SEVERITY_CODE(4) |
| 4 | warn |
SYSLOG_SEVERITY_CODE(4) |
| 5 | notice |
SYSLOG_SEVERITY_CODE(5) |
| 6 | info |
SYSLOG_SEVERITY_CODE(6) |
| 6 | log |
SYSLOG_SEVERITY_CODE(6) |
| 7 | debug |
SYSLOG_SEVERITY_CODE(7) |
Example usage for the set-severity() rewrite function
The following examples use the set-severity() rewrite function.
Using a named value:
rewrite {
set-severity("info");
};
Using a numeric value:
rewrite {
set-severity("6");
};
Using a template:
rewrite {
set-severity("${.json.severity}");
};
Options
The set-severity() rewrite rule has the following option.
<!-- This file is under the copyright of Axoflow, and licensed under Apache License 2.0, except for using the Axoflow and AxoSyslog trademarks. -->
condition()
| Type: | filter expression |
| Default: | N/A |
Description: Applies the rewrite rule only to the messages that match the specified filter expression. Messages that don’t match the filter pass through the rule unmodified, and continue to the next element of the log path. You can use any filter expression here, and you can reference an existing filter with the filter() function. For details, see Conditional rewrites.