1

I would like to trim leading and trailing spaces from the msg field using rsyslog. I read it has functions called rtrim and ltrim but I can't find any explanation of how to use functions in RainierScript. I would really appreciate if someone can show an example of these functions. My current config is like this:

module(load="imudp") input(type="imudp" port="514" ruleset="forward") template(name="RFC5424_IP" type="string" string="<%PRI%>1 %timegenerated:::date-rfc3339% %fromhost-ip% %APP-NAME% %PROCID% %MSGID% %STRUCTURED-DATA% %msg%" ) ruleset(name="forward") { action(type="omfwd" protocol="tcp" target="127.0.0.1" port="40514" Template="RFC5424_IP" TCP_Framing="octet-counted" ) } 

1 Answer 1

1

You can use set to create a new json variable, typically of the same name, at the top of a tree of json values, and then refer to the variable in the template, as in the following.

template(name="RFC5424_IP" type="string" string="... %$!msg%" ) ruleset(name="forward") { set $!msg = rtrim(ltrim($msg)); action(type="omfwd" ... ) } 

Don't forget the terminating semi-colon (;)! See Variable property types

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.