[rsyslog-notify] Forum Thread: Regular Expression Multiple Properties - (Mode 'post')
noreply at adiscon.com
noreply at adiscon.com
Fri Jun 17 17:27:55 CEST 2016
User: drclough
Forumlink: http://kb.monitorware.com/viewtopic.php?p=26616#p26616
Message:
----------
Good morning -
I am new to Rsyslog and this is my first time posting on this forum. I
have searched for this topic in the documentation and in the forum but
unfortunately have not seen this addressed.
I have a configuration which is accepting as input a single TCP stream, and
I want it to split this stream into various outputs based on message
content, and am attempting to do this with a regular expression. The
regular expression is looking at 2 properties.
Here is my question... Is there a way to read the input once, assign both
the properties to variables with one expression, then use the variables to
build the filenames accordingly?
%STRUCTURED-DATA:R,ERE,[b:18bklull]2[/b:18bklull],DFLT:ApplicationLoggingService
- (info|error).+logApplicationId#([a-zA-Z1-9_ ]+)\#--end% ----> assign
once to $logLevel, $logApplicationId
Or do I need to run this statement twice - once with submatch of '1' and
again with submatch '2'? The latter option works, but it seems fairly
inefficient.
For reference, here is my full configuration:
--------------------------------------------------------
#reset default for file creation
$umask 0000
#Pre-existing defaults
# Use traditional timestamp format
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
# Provides kernel logging support (previously done by rklogd)
$ModLoad imklog
# Provides support for local system logging (e.g. via logger command)
$ModLoad imuxsock
# New for iApi logging
# Provides support TCP commands (new ranier script format)
module(load="imtcp")
# Log to application file based on contents of logApplicationID# metric in
the message
#template(name="userFilePath" type="string"
string="/home/logtest/iapi_log_info_%STRUCTURED-DATA:R,ERE,1,DFLT:logApplicationId#([a-zA-Z1-9_
]+)\\#--end%.log")
template(name="userFilePath" type="string"
string="/home/logtest/iapi_log_%STRUCTURED-DATA:R,ERE,1,DFLT:ApplicationLoggingService
-
(info|error)--end%_%STRUCTURED-DATA:R,ERE,1,DFLT:logApplicationId#([a-zA-Z1-9_
]+)\\#--end%.log")
# Log output format - 95% of the log information will likely be in the
STRUCTURED-DATA area
template(name="Rfc5424Format" type="string" string="<%PRI%>1
%TIMESTAMP:::date-rfc3339% %HOSTNAME% %APP-NAME% %PROCID% %MSGID%
%STRUCTURED-DATA%\n")
# *Provides support for iapi logging from the application logging service
# Anything sent to this port will be logged and sent no further
ruleset(name="iapilog") {
# action(type="omfile" DynaFile="userFilePath" fileCreateMode="0644"
template="RSYSLOG_DebugFormat")
action(type="omfile" DynaFile="userFilePath" fileCreateMode="0644"
template="Rfc5424Format") stop
}
input(type="imtcp" port="514" ruleset="iapilog")
# Log all kernel messages to the console.
# Logging much else clutters up the screen.
#kern.* /dev/console
# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;authpriv.none;cron.none /var/log/messages
# The authpriv file has restricted access.
authpriv.* /var/log/secure
# Log all the mail messages in one place.
mail.* -/var/log/maillog
# Log cron stuff
cron.* /var/log/cron
# Everybody gets emergency messages
#Not any more... *.emerg *
# Save news errors of level crit and higher in a special file.
uucp,news.crit /var/log/spooler
# Save boot messages also to boot.log
local7.* /var/log/boot.log
More information about the rsyslog-notify
mailing list