mike _
2015-10-23 11:04:09 UTC
I'm using rsyslog 8.8.0 from Fedora 22 repos.
I'm trying to format logs in to JSON and send them to a remote
logstash instance. I have that working. But I also want to run
everything through mmnormalize to extract info from some log entries
and I cannot that make that work at all.
This works for formatting the logs and sending them to logstash:
[***@foo]# cat /etc/rsyslog.d/tologstash.conf
module(load="mmnormalize")
global (
defaultNetstreamDriverCAFile="/etc/pki/tls/certs/ca-bundle.pem"
)
template(name="logstash" type="list"){
constant(value="{")
property(name="msg" outname="message" format="jsonfr" droplastlf="on")
constant(value=",")
property(name="pri" outname="priority_code" format="jsonfr")
constant(value=",")
property(name="pri-text" outname="priority" format="jsonfr")
constant(value=",")
property(name="syslogfacility" outname="facility_code" format="jsonfr")
constant(value=",")
property(name="syslogfacility-text" outname="facility" format="jsonfr")
constant(value=",")
property(name="syslogseverity" outname="severity_code" format="jsonfr")
constant(value=",")
property(name="syslogseverity-text" outname="severity" format="jsonfr")
constant(value=",")
property(name="timereported" outname="syslog_timestamp"
format="jsonfr" dateformat="rfc3339")
constant(value=",")
property(name="hostname" outname="hostname" format="jsonfr")
constant(value=",")
property(name="syslogtag" outname="syslog_tag" format="jsonfr")
constant(value=",")
property(name="programname" outname="program" format="jsonfr")
constant(value="}")
}
action(type="omfwd"
target="logstash.hostname"
port="10515"
protocol="tcp"
StreamDriver="gtls"
StreamDriverMode="1"
StreamDriverAuthMode="anon"
queue.filename="logstashqueue"
queue.spoolDirectory="/var/lib/rsyslog"
queue.maxdiskspace="1g"
queue.type="LinkedList"
queue.saveonshutdown="on"
queue.size="5000"
queue.highwatermark="3500"
queue.lowwatermark="2000"
queue.discardmark="5000"
template="logstash"
action.resumeinterval="60"
action.resumeretrycount="-1"
)
[***@foo]#
With that config logs go to logstash.hostname and also in to various
files in /var/log as specified in the default rsyslog.conf.
When I introduce another action for mmnormalize just before the action
that's already there:
action(type="mmnormalize" ruleBase="/etc/rsyslog.d/sshd.rb")
action(type="omfwd"
Where sshd.rb looks like:
[***@foo]# cat /etc/rsyslog.d/sshd.rb
rule=sshd_accepted_password:%-:string-to: Accepted% Accepted password
for %ssh_user:word% from %remote_ip:ipv4% %-:rest%
[***@foo]#
Then the result is that nothing is sent to logstash.hostname and
nothing goes in the files in /var/log/ either.
I have observed that if I specify no file for the rulebase, or if I
specify a non-existent file, then logs reachlogstash.hostname and
/var/log/
One question I have is: what happens to log entries which do not match
any rules in the file specified by ruleBase?
I can't find a definitive answer to that question. I was wondering
whether maybe the problem is that if a log entry doesn't match any
rule then it is effectively discarded. But if that were the case I
would expect to have found people talking about the need to use a rule
which matches any log entry to ensure it isn't discarded and I
haven't. A colleague has a working example with mmnormlize where
they're parsing a specified file with a named ruleset, and experiments
on that show that log entries which don't match any rules in the
ruleBase file reach logstash. If I replace sshd.rb with their ruleBase
I also get no output.
This log entry, obtained without the mmnormalize action in place,
matches the rule in sshd.rb
[***@foo]# echo "Oct 22 10:15:43 foo sshd[7217]: Accepted password
for mike from 192.168.2.100 port 43090 ssh2" | lognormalizer -r
/etc/rsyslog.d/sshd.rb
[***@115 event.tags="sshd_accepted_password" remote_ip="192.168.2.100"
ssh_user="mike"]
[***@foo]#
If, with the mmnormalize action in place, I repeat the action which
generates a log entry like that, I still get no output anywhere. So
I'm thinking the problem probably isn't nothing matches the rule
therefore no output.
I've run rsyslog in debug mode and lots and lots of stuff is output
including messages such as
4377.155829288:imjournal.c : main Q: EnqueueMsg advised worker start
4382.205117764:imjournal.c : main Q: qqueueAdd: entry added, size
now log 670, phys 672 entries
4382.205134783:imjournal.c : main Q: EnqueueMsg advised worker start
4382.205246089:imjournal.c : main Q: qqueueAdd: entry added, size
now log 671, phys 673 entries
4382.205254910:imjournal.c : main Q: EnqueueMsg advised worker start
4382.205373987:imjournal.c : main Q: qqueueAdd: entry added, size
now log 672, phys 674 entries
Which makes me think rsyslog is at least taking log entries in, but if
the explanation of why nothing is coming out is in the debug output I
can't recognise it.
I feel like I'm doing something fundamentally wrong, but I've no idea
what. Any explanation/guidance would be much appreciated.
thanks,
mike
_______________________________________________
rsyslog mailing list
http://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com/professional-services/
What's up with rsyslog? Follow https://twitter.com/rgerhards
NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad of sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you DON'T LIKE THAT.
I'm trying to format logs in to JSON and send them to a remote
logstash instance. I have that working. But I also want to run
everything through mmnormalize to extract info from some log entries
and I cannot that make that work at all.
This works for formatting the logs and sending them to logstash:
[***@foo]# cat /etc/rsyslog.d/tologstash.conf
module(load="mmnormalize")
global (
defaultNetstreamDriverCAFile="/etc/pki/tls/certs/ca-bundle.pem"
)
template(name="logstash" type="list"){
constant(value="{")
property(name="msg" outname="message" format="jsonfr" droplastlf="on")
constant(value=",")
property(name="pri" outname="priority_code" format="jsonfr")
constant(value=",")
property(name="pri-text" outname="priority" format="jsonfr")
constant(value=",")
property(name="syslogfacility" outname="facility_code" format="jsonfr")
constant(value=",")
property(name="syslogfacility-text" outname="facility" format="jsonfr")
constant(value=",")
property(name="syslogseverity" outname="severity_code" format="jsonfr")
constant(value=",")
property(name="syslogseverity-text" outname="severity" format="jsonfr")
constant(value=",")
property(name="timereported" outname="syslog_timestamp"
format="jsonfr" dateformat="rfc3339")
constant(value=",")
property(name="hostname" outname="hostname" format="jsonfr")
constant(value=",")
property(name="syslogtag" outname="syslog_tag" format="jsonfr")
constant(value=",")
property(name="programname" outname="program" format="jsonfr")
constant(value="}")
}
action(type="omfwd"
target="logstash.hostname"
port="10515"
protocol="tcp"
StreamDriver="gtls"
StreamDriverMode="1"
StreamDriverAuthMode="anon"
queue.filename="logstashqueue"
queue.spoolDirectory="/var/lib/rsyslog"
queue.maxdiskspace="1g"
queue.type="LinkedList"
queue.saveonshutdown="on"
queue.size="5000"
queue.highwatermark="3500"
queue.lowwatermark="2000"
queue.discardmark="5000"
template="logstash"
action.resumeinterval="60"
action.resumeretrycount="-1"
)
[***@foo]#
With that config logs go to logstash.hostname and also in to various
files in /var/log as specified in the default rsyslog.conf.
When I introduce another action for mmnormalize just before the action
that's already there:
action(type="mmnormalize" ruleBase="/etc/rsyslog.d/sshd.rb")
action(type="omfwd"
Where sshd.rb looks like:
[***@foo]# cat /etc/rsyslog.d/sshd.rb
rule=sshd_accepted_password:%-:string-to: Accepted% Accepted password
for %ssh_user:word% from %remote_ip:ipv4% %-:rest%
[***@foo]#
Then the result is that nothing is sent to logstash.hostname and
nothing goes in the files in /var/log/ either.
I have observed that if I specify no file for the rulebase, or if I
specify a non-existent file, then logs reachlogstash.hostname and
/var/log/
One question I have is: what happens to log entries which do not match
any rules in the file specified by ruleBase?
I can't find a definitive answer to that question. I was wondering
whether maybe the problem is that if a log entry doesn't match any
rule then it is effectively discarded. But if that were the case I
would expect to have found people talking about the need to use a rule
which matches any log entry to ensure it isn't discarded and I
haven't. A colleague has a working example with mmnormlize where
they're parsing a specified file with a named ruleset, and experiments
on that show that log entries which don't match any rules in the
ruleBase file reach logstash. If I replace sshd.rb with their ruleBase
I also get no output.
This log entry, obtained without the mmnormalize action in place,
matches the rule in sshd.rb
[***@foo]# echo "Oct 22 10:15:43 foo sshd[7217]: Accepted password
for mike from 192.168.2.100 port 43090 ssh2" | lognormalizer -r
/etc/rsyslog.d/sshd.rb
[***@115 event.tags="sshd_accepted_password" remote_ip="192.168.2.100"
ssh_user="mike"]
[***@foo]#
If, with the mmnormalize action in place, I repeat the action which
generates a log entry like that, I still get no output anywhere. So
I'm thinking the problem probably isn't nothing matches the rule
therefore no output.
I've run rsyslog in debug mode and lots and lots of stuff is output
including messages such as
4377.155829288:imjournal.c : main Q: EnqueueMsg advised worker start
4382.205117764:imjournal.c : main Q: qqueueAdd: entry added, size
now log 670, phys 672 entries
4382.205134783:imjournal.c : main Q: EnqueueMsg advised worker start
4382.205246089:imjournal.c : main Q: qqueueAdd: entry added, size
now log 671, phys 673 entries
4382.205254910:imjournal.c : main Q: EnqueueMsg advised worker start
4382.205373987:imjournal.c : main Q: qqueueAdd: entry added, size
now log 672, phys 674 entries
Which makes me think rsyslog is at least taking log entries in, but if
the explanation of why nothing is coming out is in the debug output I
can't recognise it.
I feel like I'm doing something fundamentally wrong, but I've no idea
what. Any explanation/guidance would be much appreciated.
thanks,
mike
_______________________________________________
rsyslog mailing list
http://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com/professional-services/
What's up with rsyslog? Follow https://twitter.com/rgerhards
NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad of sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you DON'T LIKE THAT.