How to set variables in rsyslog v7
With rsyslog 7.1.3 we introduced the opportunity to set variables inside the rsyslog.conf. Though, this does not work with standard properties, this can be done with CEE/lumberjack-type properties. Variable customization should be considered an aid for template generation and modification.
Note that CEE/lumberjack properties, as implemented in rsyslog, can be hierarchical and levels are delimited by the bang sign (based on lumberjack recommendations). So “!uid” is the uid field in the CEE root, whereas “!usr!uid” is the uid field inside the usr container. Nesting can be as deep as desired. Currently, all parts of the CEE tree can be accessed. In later versions, this may require the setting of a global option.
A variable can be set by using the following:
set varname = expression;
Please note the semicolon at the end. This is needed to separate from other config lines as well as to keep compatibility with older versions. The expression can be an arbitrary complex expression, just like in an “if” statement.
Concrete examples:
set $!usr!level2!var1 = "test"; set $!usr!level2!var1 = $msg; # update variable with native MSG field set $!usr!level2!var2 = 1+1; # set !usr!level2!var2 = 2 set $!usr!level2 = $fromhost; # invalid
The last example is invalid because it tries to replace a complete container with the content of a single regular property.
There is also an accompanying “unset” statement to remove a variable that is no longer needed. This is primarily meant to restructure a CEE container. It’s syntax simply is:
unset varname;
Again, note the semicolon at the end. A concrete example is
unset !usr!level2!var1;
which removes a single element. But full containers can also be removed:
unset !usr!level2
Note that all variables are assigned to the message currently being processed. There currently is no way to set global variables.
rsyslog 7.1.3 (v7-devel)
Download file name: rsyslog 7.1.3 (devel)
rsyslog 7.1.3 (devel)
sha256 hash: 43b2da70c570776963155bbde9537ef8d85369240e687969720ba47223e2f1c1
Author: Rainer Gerhards (rgerhards@adiscon.com)
Version: 7.1.3 File size: 2.587 MB
Changelog for 7.1.3 (v7-devel)
Version 7.1.3 [devel] 2012-09-17
- introduced “set” and “unset” config statements
- bugfix: missing support for escape sequences in RainerScript only \’ was supported. Now the usual set is supported. Note that v5 used \x as escape where x was any character (e.g. “\n” meant “n” and NOT LF). This also means there is some incompatibility to v5 for well-know sequences. Better break it now than later.
- bugfix: invalid property name in property-filter could cause abort if action chaining (& operator) was used
http://bugzilla.adiscon.com/show_bug.cgi?id=355
Thanks to pilou@gmx.com for the bug report
rsyslog 7.1.2 (v7-devel) released
This is a bugfixing release vor the v7 development branch. It includes critical fixes for a message duplication bug, a bug when using multiple rulesets and some more. For more information please take a look into the ChangeLog.
ChangeLog:
http://www.rsyslog.com/changelog-for-7-1-2-v7-devel/
Download:
http://www.rsyslog.com/rsyslog-7-1-2-v7-devel/
As always, feedback is appreciated.
Best regards,
Florian Riedl
rsyslog 7.1.2 (v7-devel)
Download file name: rsyslog 7.1.2 (devel)
rsyslog 7.1.2 (devel)
sha256 hash: ee3443b4b1a6792356a8b1d3aa46b7d77be984ebf51516f0e69569096e923920
Author: Rainer Gerhards (rgerhards@adiscon.com)
Version: 7.1.2 File size: 2.582 MB
Changelog for 7.1.2 (v7-devel)
Version 7.1.2 [devel] 2012-09-12
- bugfix: messages were duplicated, sometimes massively regression from new code in 7.1.1 and reason for early release
- bugfix: remove invalid socket option call from imuxsock
Thanks to Cristian Ionescu-Idbohrn and Jonny Törnbom - bugfix: abort when invalid property name was configured in property-based filter
- bugfix: multiple rulesets did no longer work correctly (7.1.1 regression)
rsyslog 7.1.1 (v7-devel) released
This is the first release that supports the new rule engine, which in turn supports unlimited nesting inside rsyslog.conf. Note that the new rule engine also supports if … then … else … constructs. This new engine lays the foundation for all other work to be done in v7. As discussed on the mailing list, BSD-style blocks are no longer supported.
ChangeLog:
http://www.rsyslog.com/changelog-for-7-1-1-v7-devel/
Download:
http://www.rsyslog.com/rsyslog-7-1-1-v7-devel/
As always, feedback is appreciated.
Best regards,
Florian Riedl
rsyslog 7.1.0 (v7-devel) released
This release kicks off rsyslog v7. Version 7.1.0 is very similar to v6-devel, except that it contains the important capability to work with hierarchical properties. Note that this version does not yet contain the new ruleengine work – this will be part of the next v7 release. This release is primarily intended for those interested in working with the hierarchical properties. Note that the code obviously is currently in a somewhat experimental state.
ChangeLog:
http://www.rsyslog.com/changelog-for-7-1-0-v7-devel/
Download:
http://www.rsyslog.com/rsyslog-7-1-0-v7-devel/
As always, feedback is appreciated.
Best regards,
Florian Riedl
Changelog for 7.1.0 (v7-devel)
Version 7.1.0 [devel] 2012-09-06
- added support for hierarchical properties (CEE/lumberjack)
- added pure JSON output plugin parameter passing mode
- ommongodb now supports templates
- bugfix: imtcp could abort on exit due to invalid free()
- imported bugfixes from 6.4.1
rsyslog 6.4.1 (v6-stable) released
We have just released 6.4.1 of the v6-stable branch. This is primarily a maintenance release. It includes several bugfixes for using JSON, if you are using multiple main queues and many more. More details can be found in the ChangeLog.
ChangeLog:
http://www.rsyslog.com/changelog-for-6-4-1-v6-stable/
Download:
http://www.rsyslog.com/rsyslog-6-4-1-v6-stable/
As always, feedback is appreciated.
Best regards,
Florian Riedl
