mirror of
https://github.com/rsyslog/rsyslog.git
synced 2025-12-20 01:30:42 +01:00
The variable system inside rsyslog is JSON based (for easy consumption
of JSON input, the prime source of structured data). In JSON, keys
("variable names") are case-sensitive. This causes constant problems
inside rsyslog configurations. A major nit is that case-insensitivity
option inside templates (even if turned on) does not work with JSON
keys because they of inner workings*1.
It is much more natural to treat keys in a case-INsensitive way (e.g.
"$!Key" and "$!key" are the same). We do not expect any real problems
out of this, as key names only differing in case is highly unlikely.
However, as it is possible we provide a way to enable case-sensitivity
via the global(variables.casesensitve="on") global config object.
Note that the default is to do case-insensitive matches. The reason
is that this is the right thing to do in almost all cases, and we do
not envision any problems at all in existing deployments.
*1 Note: case-insensitivity in rsyslog is achieved by converting all
names to lower case. So that the higher speed of strcmp() can be used.
The template option does actually that, convert the template keys to
lower case. Unfortunately, this does not work with JSON, as JSON keys
are NOT converted to lower case.
closes https://github.com/rsyslog/rsyslog/issues/1805
16 lines
706 B
Plaintext
16 lines
706 B
Plaintext
$IncludeConfig diag-common.conf
|
|
global(variables.casesensitive="on")
|
|
module(load="../plugins/mmjsonparse/.libs/mmjsonparse")
|
|
module(load="../plugins/imtcp/.libs/imtcp")
|
|
input(type="imtcp" port="13514")
|
|
|
|
# we must make sure the template contains references to the variables
|
|
template(name="outfmt" type="string" string="abc:%$!abc% ABC:%$!ABC% aBc:%$!aBc% _abc:%$!_abc% _ABC:%$!_ABC% _aBc:%$!_aBc%\n" option.casesensitive="on")
|
|
template(name="outfmt-all-json" type="string" string="%$!all-json%\n")
|
|
|
|
action(type="mmjsonparse")
|
|
set $!_aBc = "7";
|
|
action(type="omfile" file="./rsyslog.out.log" template="outfmt")
|
|
if $!_aBc != "7" then
|
|
action(type="omfile" file="./rsyslog2.out.log" template="outfmt-all-json")
|