I have a log line that looks like this:
May 20 10:25:42 192.168.20.100 Timestamp="2024-05-20 10:25:42",LogId="535666280",NodeId="192.168.1.100",Facility="Packet Filtering",Type="Notification",Event="Connection discarded",Action="Discard",Protocol="1",Src="10.0.0.10",Dst="10.10.10.10",RuleId="21.0",Srcif="0",IcmpType="11",IcmpCode="0",CompId="Limes node 1",ReceptionTime="2024-05-20 10:25:42",SenderType="Firewall",SituationId="70019",Situation="Connection_Discarded",EventId="7198237666637962215",Service="Time Exceeded (TTL Exceeded)"^J
and I'd like to use the value of NodeId as part of the path to write the log to disk.
I've created a path template like so:
template (name="DynFile" type="list") {
constant(value="/var/log/my/path/")
property(name="$!customfromhost")
constant(value=".log")
}
And I try to use mmnormalize to set the customfromhost variable:
ruleset(name="parsecsv") {
action(type="mmnormalize" rule=["rule=:%logtime:date-rfc3164% %logsender:ipv4% Timestamp=%timestamp:quoted-string%,LogId=%logid:quoted-string%,NodeId=%gurkafromhost:quoted-string%,%rest:rest%"])
action(type="omfile" dynaFile="DynFile")
}
I've defined input to use the ruleset like so:
input(type="imudp" port="514" ruleset="parsecsv")
The log ends up in /var/log/my/path/.log - so something is wrong with my variable - either the way I reference it or the way it is set.
I've tried verifying my rule by calling lognormalizer directly which seem to work:
$ cat ruleBase.rb
rule=:%logtime:date-rfc3164% %logsender:ipv4% Timestamp=%timestamp:quoted-string%,LogId=%logid:quoted-string%,NodeId=%customfromhost:quoted-string%,%rest:rest%
$ cat line.log
May 20 10:25:42 192.168.20.100 Timestamp="2024-05-20 10:25:42",LogId="535666280",NodeId="192.168.1.100",Facility="Packet Filtering",Type="Notification",Event="Connection discarded",Action="Discard",Protocol="1",Src="10.0.0.10",Dst="10.10.10.10",RuleId="21.0",Srcif="0",IcmpType="11",IcmpCode="0",CompId="Limes node 1",ReceptionTime="2024-05-20 10:25:42",SenderType="Firewall",SituationId="70019",Situation="Connection_Discarded",EventId="7198237666637962215",Service="Time Exceeded (TTL Exceeded)"^J
$ cat line.log | lognormalizer -rruleBase.rb
{ "rest": "Facility=\"Packet Filtering\",Type=\"Notification\",Event=\"Connection discarded\",Action=\"Discard\",Protocol=\"1\",Src=\"10.0.0.10\",Dst=\"10.10.10.10\",RuleId=\"21.0\",Srcif=\"0\",IcmpType=\"11\",IcmpCode=\"0\",CompId=\"Limes node 1\",ReceptionTime=\"2024-05-20 10:25:42\",SenderType=\"Firewall\",SituationId=\"70019\",Situation=\"Connection_Discarded\",EventId=\"7198237666637962215\",Service=\"Time Exceeded (TTL Exceeded)\"^J", "customfromhost": "192.168.1.100", "logid": "535666280", "timestamp": "2024-05-20 10:25:42", "logsender": "192.168.20.100", "logtime": "May 20 10:25:42" }
The installed rsyslog is the default version for CentOS-STREAM9:
# dnf info rsyslog
Last metadata expiration check: 0:11:45 ago on Mon 20 May 2024 12:57:06 PM CEST.
Installed Packages
Name : rsyslog
Version : 8.2310.0
Release : 4.el9
Architecture : x86_64
Size : 2.6 M
Source : rsyslog-8.2310.0-4.el9.src.rpm
Repository : @System
From repo : appstream
What am I doing wrong?