Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use $msgid to filter rsyslog message #3592

Closed
minhtuanmt1 opened this issue Apr 5, 2019 · 5 comments
Closed

Can't use $msgid to filter rsyslog message #3592

minhtuanmt1 opened this issue Apr 5, 2019 · 5 comments
Labels

Comments

@minhtuanmt1
Copy link

Hi All,

I'm using rsyslog 8.4.0 and try to log a msg with RFC5424 with msgid.
For example:
logger "Testing testing" --msgid "testmsgid" --rfc5424

But when I configure the rsyslog.conf to filter the msg base on msgid, I can't see that log msg.
Here is my rsyslog.conf
if $msgid contains "testmsgid" then {
. /var/log/test.log
}

I still can see "testmsgid" in the rawmsg, but I can fetch it via variable $msgid.

Does anyone has any idea how to fetch msgid field? Or is this a known problem in rsyslog?

Thanks a lot for your support,
Tom

@rgerhards
Copy link
Member

Not sure if the old version supports that, but in current rsyslog you can disable the special parser:

module(load="imuxsock" SysSock.UseSpecialParser="off")

more info: https://www.rsyslog.com/doc/v8-stable/configuration/modules/imuxsock.html

@davidelang
Copy link
Contributor

davidelang commented Apr 5, 2019 via email

@minhtuanmt1
Copy link
Author

minhtuanmt1 commented May 14, 2019

Hi Rainer Gerhards and David Lang,

module(load="imuxsock" SysSock.UseSpecialParser="off")
I tried but it doesn't work. I still can't fetch value for msgid attribute.

I tried to use RSYSLOG_DebugFormat and log a test message and it seems there is no msgid field at all. Please see log example below:

logger "Testing testing" --msgid "testmsgid" --rfc5424

Debug line with all properties:
FROMHOST: 'node1', fromhost-ip: '127.0.0.1', HOSTNAME: 'node1', PRI: 13,
syslogtag '1', programname: '1', APP-NAME: '1', PROCID: '-', MSGID: '-',
TIMESTAMP: 'May 14 04:29:21', STRUCTURED-DATA: '-',
msg: ' 2019-05-14T04:29:21.355498+02:00 node1 root - testmsgid [timeQuality tzKnown="1" isSynced="1" syncAccuracy="538958"] Testing testing'
escaped msg: ' 2019-05-14T04:29:21.355498+02:00 node1 root - testmsgid [timeQuality tzKnown="1" isSynced="1" syncAccuracy="538958"] Testing testing'
inputname: imuxsock rawmsg: '<13>1 2019-05-14T04:29:21.355498+02:00 node1 root - testmsgid [timeQuality tzKnown="1" isSynced="1" syncAccuracy="538958"] Testing testing'
$!:
$.:
$/:

Do you know why MSGID: '-'? It supposed to be "testmsgid" in this example.

Thanks and regards,
Tuan

@rgerhards
Copy link
Member

answer in #3592 (comment)

@machta
Copy link

machta commented Feb 11, 2023

Just to clarify in case somebody doesn't get it like me when I read this thread for the first time:

Rsyslog doesn't support the RFC5424 format by default. You have to turn this "UseSpecialParser" off. Only then will it recognize this msgid field (as well as the structured-data) coming from tools like logger that support this format.

Another gotcha I found is that it's impossible to write a message in this format using the POSIX syslog() function, because it always adds the old-style header. The logger utility doesn't use this function but writes to the UNIX socket directly, and that's why it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants