On Tue, 26 Jan 2016, John Tabasz wrote:

So to set a variable, you must use $! where in bash a $ is all that's
needed?
How do you interpret this:

set $!usr!level2!var1 = "test";
set $!usr!level2!var1 = $msg; # update variable with native MSG field

What's the purpose of the ! between usr and level2? Based on your
response the name of the variable

is "usr!level2!var1". Is this a true statement?

Is there somewhere that the scripting language syntax is detailed?

getting deep into technical details here as I think you need them to understand what's going on here

There are actually only three user definable variables in rsyslog

$! $. and $\

But these are defined to be JSON

so

set $!usr!level2!var = "test";

really defines

$!= {'usr': {'level2': {'var': 'test'}}}

$! is the default variable (or set of variables depending how you look at it), and is what is used in all the documentation.

$. was created because it's very handy to be able to use $! in a template to send everything as a JSON string to another server or to a filej, but sometimes you need additional variables for housekeeping purposes (dynamic filename path generation for example), so they are referred to as 'local variables', but really should operate just like $! except that $! is the default location for parsers to put data extracted from the log messages.

both $! and $. only exist for the log message you are processing. because you sometimes need to set conditions or maintain counters across different log messages, the $\ global variable set was introduced. it's substantially more expensive to use than the other two, but persists from one log message to the next (note that due to parallel processing of messages, setting a $\ variable in one message should be viewed as setting it 'soon' in terms of other messages, a message that has arrived later may already have been processed due to a number of conditions, including network based reasons)

does this clarify things for you?

David Lang
_______________________________________________
rsyslog mailing list
http://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com/professional-services/
What's up with rsyslog? Follow https://twitter.com/rgerhards
NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad of 
sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you DON'T LIKE 
THAT.

Reply via email to