Setting severity with the set-severity() rewrite function

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.

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 CodeNamed ValueAlias
0emergSYSLOG_SEVERITY_CODE(0)
0emergencySYSLOG_SEVERITY_CODE(0)
0panicSYSLOG_SEVERITY_CODE(0)
1alertSYSLOG_SEVERITY_CODE(1)
2critSYSLOG_SEVERITY_CODE(2)
2criticalSYSLOG_SEVERITY_CODE(2)
2fatalSYSLOG_SEVERITY_CODE(2)
3errSYSLOG_SEVERITY_CODE(3)
3errorSYSLOG_SEVERITY_CODE(3)
4warningSYSLOG_SEVERITY_CODE(4)
4warnSYSLOG_SEVERITY_CODE(4)
5noticeSYSLOG_SEVERITY_CODE(5)
6infoSYSLOG_SEVERITY_CODE(6)
6logSYSLOG_SEVERITY_CODE(6)
7debugSYSLOG_SEVERITY_CODE(7)

Example usage for the set-severity() rewrite function

The following examples can be used in production for the set-severity() rewrite function.

Example using string:

   rewrite {
        set-severity("info");
    };

Example using numeric string:

   rewrite {
        set-severity("6");
    };

Example using template:

   rewrite {
        set-severity("${.json.severity}");
    };
Last modified January 28, 2024: [4.6] Adds aliases to set-severity (8df4f28)