There are logs coming from a program (namely supervisord) entering rsyslog. Their message starts with " real-program-name rest of the message"
, and I'm trying to:
- Set the programname to
real-program-name
instead of supervisord - Remove the programname from the message.
I'm currently doing this:
if ($programname == "supervisord") then {
set $.programname = re_extract($msg, "^ ([^ ]+)", 0, 1, $programname);
set $.msg = re_extract($msg, "^ [^ ]+ (.+)", 0, 1, $msg);
}
(edit : I've tried with $!
instead of $.
, same problem)
The following line in my config file/script is
if ($programname startswith "real") then {...}
So the logs tell me if programname was actually replaced with real-program-name
The logs say :
processBATCH: next msg 0: <14>Nov 22 10:51:55 supervisord: real-program-name 127.0.0.1 - - [22/Nov/2017:10:51:55 +0000] "GET /blabla
IF
var 'programname'
==
string 'supervisord'
eval expr 0x1a4e0b0, type 'CMP_EQ'
eval expr 0x1a4dcd0, type 'V'
rainerscript: (string) var 17: 'supervisord'
eval expr 0x1a4dcd0, return datatype 'S':0
eval expr 0x1a4e0b0, return datatype 'N':1
if condition result is 1
SET .programname =
function 're_extract' (id:8, params:5)
var 'msg'
string '^ ([^ ]+)'
0
1
var 'programname'
END SET
eval expr 0x1a4e270, type 'F'
rainerscript: executing function id 8
eval expr 0x1a4dd00, type 'V'
rainerscript: (string) var 1: ' real-program-name 127.0.0.1 - - [22/Nov/2017:10:51:55 +0000] "GET /blabla" "Mozilla/5.0 (X11; Linux x86_64; rv:57.0) Gecko/20100101 Firefox/57.0"'
eval expr 0x1a4dd00, return datatype 'S':0
eval expr 0x1a4e170, type 'N'
eval expr 0x1a4e170, return datatype 'N':0
eval expr 0x1a4e190, type 'N'
eval expr 0x1a4e190, return datatype 'N':1
re_extract: regexec return is 0
re_extract: regex: end search, found 1
eval expr 0x1a4e270, return datatype 'S':0
SET .msg =
function 're_extract' (id:8, params:5)
var 'msg'
string '^ [^ ]+ (.+)'
0
1
var 'msg'
END SET
eval expr 0x1a53290, type 'F'
rainerscript: executing function id 8
eval expr 0x1a534e0, type 'V'
rainerscript: (string) var 1: ' real-program-name 127.0.0.1 - - [22/Nov/2017:10:51:55 +0000] "GET /blabla HTTP/1.0" 200 - "" "Mozilla/5.0 (X11; Linux x86_64; rv:57.0) Gecko/20100101 Firefox/57.0"'
eval expr 0x1a534e0, return datatype 'S':0
eval expr 0x1a53160, type 'N'
eval expr 0x1a53160, return datatype 'N':0
eval expr 0x1a53180, type 'N'
eval expr 0x1a53180, return datatype 'N':1
re_extract: regexec return is 0
re_extract: regex: end search, found 1
eval expr 0x1a53290, return datatype 'S':0
IF
var 'programname'
STARTSWITH
string 'real'
eval expr 0x1a545f0, type 'CMP_STARTSWITH'
eval expr 0x1a546b0, type 'V'
rainerscript: (string) var 17: 'supervisord'
eval expr 0x1a546b0, return datatype 'S':0
eval expr 0x1a545f0, return datatype 'N':0
if condition result is 0
Which I interpret as : the log comes form supervisor, the regex extraction went well but the set
had no effect.
What am I doing wrong ?