I'm new to Logstash and I was wondering if someone could point me in the right direction. I'm using Logstash version 2.4 and setup this filter to parse out IIS logs from Azure. If I comment out the data section everything parses correctly but the @timestamp of the record is the import date not the event date (I have to load a lot of old data so it's important that it's by even date). When the date section is enabled so that it should use the event date (logtimestamp) as the event date then I get a Tag _grokparsefailure. None of the fields are parsed and there is not a _dateDidNotMatch tag. I'm not seeing anything in the log files that would indicate an error and I'm not sure what I'm doing wrong... Is there something wrong with my syntax or logic?
-thanks
filter {
# Ignore log comments
if [message] =~ "^#" {
drop {}
}
grok {
# Check that fields match your IIS log settings
match => ["message", "%{YEAR:year}-%{MONTHNUM:month}-%{MONTHDAY:day} %{TIME:time} %{IPORHOST:site} %{WORD:method} %{URIPATHPARAM:page} %{NOTSPACE:querystring} %{NUMBER:port} %{NOTSPACE:username} %{IPORHOST:clientip} %{NOTSPACE:useragent} %{NOTSPACE:cookie} %{NOTSPACE:referer} %{IPORHOST:hostname} %{NUMBER:status} %{NUMBER:substatus} %{NUMBER:winstatus} %{NUMBER:bytes_response} %{NUMBER:bytes_request} %{NUMBER:time_taken}"]
add_field => {
"logtimestamp" => "%{year}-%{month}-%{day} %{time}"
}
remove_field => [ "year", "month", "day", "time" ]
}
# Set the Event Timesteamp from the log
date {
match => ["logtimestamp", "yyyy-MM-dd HH:mm:ss"]
target => "@timestamp"
timezone => "UTC"
locale => "en"
tag_on_failure => ["_dateDidNotMatch"]
}
useragent {
source => "useragent"
prefix => "browser"
}
Thanks for you willingness to help me. Here is an extract from one of our log files. Didn't see a way to upload a log file so If there is a better way, I can send a copy of the whole file.
You can simplify your configuration by capturing the whole timestamp with a single grok pattern, TIMESTAMP_ISO8601. Then you can remove the add_field and remove_field options.
I also found out what the parse error was. Azure will sometimes place a '~1' in the site name for App Service Plans and the IPORHOST doesn't like that. Because all my dates where in the past, when I had the date section uncommitted I would only see the parse error (because the @timestamp is set to the current date/time) and so it looked like everything was failing. But I found that the rest of the logs where correct, but in the past beyond the scope of my query.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.