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

How to let Rsyslog parse the 'message' field as the actual syslog message #3951

Open
wtliuNA opened this issue Nov 7, 2019 · 3 comments
Open

Comments

@wtliuNA
Copy link

wtliuNA commented Nov 7, 2019

Environment

  • rsyslog version: 8.35.0
  • for configuration questions/issues, include rsyslog.conf and included config files

In our environment, we have Rsyslog instances receiving logs which are forwarded through load balancers.

With rsyslog.confg(input part) like this:

module(load="imuxsock")
module(load="imtcp")
input( Type="imtcp" Port="514" Address="address" )

template(
name="structured_json"
type="string"
string={% raw %}"{%timestamp:::date-rfc3339,jsonf:ts%,%HOSTNAME:::jsonf:hostname%,%FROMHOST-IP:::jsonf:ip%,%syslogfacility-text:::jsonf:facility%,%syslogseverity-text:::jsonf:sev%,%procid:::jsonf:pid%,%syslogtag:::jsonf:tag%,%programname:::jsonf:prog%, %msg:::jsonf%}\n"{% endraw %}
)

It seems the messages we received are parsed into:
{"ts":"2019-11-06T23:35:41+00:00","hostname":"LB_ip_addr","ip":"LB_ip_addr","facility":"user","sev":"notice","pid":"-","tag":"some_tag","prog":"some_prog", "msg":" <11>2019-10-06T23:01:55.840Z hostname1 test[1] This is the real message"}

So we want the output to be parsed from the actual syslog message that is currently nested in the 'message' field. e.g. output to be {"ts":"2019-10-06T23:01:55.840Z","hostname":"hostname1","ip":"","facility":"user","sev":"err","pid":"1","tag":"test[1]","prog":"test", "msg":" This is the real message"}

Is there a way to do that using existing modules from Rsyslog?

@davidelang
Copy link
Contributor

davidelang commented Nov 7, 2019 via email

@wtliuNA
Copy link
Author

wtliuNA commented Nov 7, 2019

Thanks @davidelang , let me standardize my question:

This is the raw syslog arrived:
Nov 7 08:40:54 794afc3bf567/794afc3bf567/11.50.3.5 <11>2019-10-06T23:01:55.840Z hostname1 test[1] This is the real message

And this is what it currently gets parsed into:
{"ts":"2019-11-07T08:40:54+00:00","hostname":"11.50.3.5","ip":"11.50.3.5","facility":"user","sev":"notice","pid":"-","tag":"794afc3bf567\/794afc3bf567","prog":"794afc3bf567", "msg":" <11>2019-10-06T23:01:55.840Z hostname1 test[1] This is the real message"}

And this is what I would expect the output to be:
{"ts":"2019-10-06T23:01:55.840Z","hostname":"hostname1","ip":"","facility":"user","sev":"err","pid":"1","tag":"test[1]","prog":"test", "msg":" This is the real message"}

@davidelang
Copy link
Contributor

davidelang commented Nov 7, 2019 via email

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

No branches or pull requests

2 participants