Im trying to parse my apache2 error log and im having a bit of trouble.. It doesnt seem to be matching the filter. Im pretty sure the timestamp piece is wrong, but im not sure, and i cant really find any documentation to figure it out. Also, is there a way to get what is in fields.errmsg
to me @message
?
Log
[Wed Jun 26 22:13:22 2013] [error] [client 10.10.10.100] PHP Fatal error: Uncaught exception '\Foo\Bar'
Shipper Config
input {
file {
'path' => '/var/log/apache2/*-error.log'
'type' => 'apache-error'
}
}
filter {
grok {
type => "apache-error"
pattern => "\[%{HTTPDATE:timestamp}\] \[%{WORD:class}\] \[%{WORD:originator} %{IP:clientip}\] %{GREEDYDATA:errmsg}"
}
}
output {
stdout {}
redis {
'data_type' => 'list'
'host' => 'logstash.server.net'
'key' => 'logstash'
}
}
Logstash has a built-in apache log parser.
Here is an example...
As a reference, you can check Logstash's docs
Didn't work for me:
Worked for me (Apache 2.4):
Our error logs look a little different:
But I found a predefined pattern that works perfectly:
See this in the Logstash source
Ahoy!
I know I'm a little late to the party, but here it goes!
I created a
/etc/logstash/patterns.d/
directory on the system and thew a file namedapache-error
in it containing:/etc/logstash/patterns.d/
will be referenced in thelogstash
configuration as follows:You can test it out at Grok Debugger, like Adam mentioned in his comment. Seems to work just fine with the sample log entry you send. Has been working pretty solidly me with one of my clients.
The pattern above puts the final message in
errormsg
field. So I just delete themessage
field.This is what I am currently using in my logstash configuration:
Note that I am using a type of
apache_error_log
instead ofapache-error
.Give it s shot. I would love to know if this works for you and others!
Cheers!