Can Rsyslog process messages before saving them

rsyslogsyslog

The messages that I'm sending to syslog have some tags like so:

"[date] [text here] tags:tag1,tag2,tag3 [more text here]"

I already have a rule that only saves lines that contain the text "tags:" to a specific file.

It would be great if that file only contained a substring of that message, in this case just the date and the tags part.

Can rsyslog do some processing/manipulation to a message prior to saving it?

Thanks in advance.

Best Answer

Yes, it can. The place to look for information is at the rsyslog documentation for property replacer. If the list of tags is always the same length, you can use substring. Otherwise you'll need to use a regexp, e.g.

%msg:R:.(tags:[\S]+).--end%