I'm trying to get grok working with logstash but struggling to get off the starting block. I've tried to simplify things down to a succinct test which is here:
require "test_utils"
describe "basic grokking" do
extend LogStash::RSpec
config <<-CONFIG
filter {
grok {
match => [ "message", "%{IP:client} %{WORD:method} %{URIPATHPARAM:request} %{NUMBER:bytes} %{NUMBER:duration}" ]
}
}
CONFIG
sample ({'@message' => '55.3.244.1 GET /index.html 15824 0.043'}) do
puts subject.inspect # view http://www.codeshare.io/OhDC0
insist { subject["client"] } == "55.3.244.1"
end
end
I get the following error:
1) basic grokking "{"@message":"55.3.244.1 GET /index.html 15824 0.043..." when processed
Failure/Error: Unable to find matching line from backtrace
Insist::Failure:
Expected "55.3.244.1", but got nil
No amount of syntax tweaking is getting a result and I also can't figure out how to inspect the subject
to find out what is there.
The ultimate aim is to use grok to extract the following HttpRequestId
:
[HttpRequestId = e29041b2-a4a0-4bf3-ba05-2de5e7bcf444] 2015/04/10 08:12:51:632 [DEBUG] ... log message ...
Using something like this:
grok {
match => [ "Message", "\[HttpRequestId = %{UUID:HttpRequestId}" ]
}
NOTE I have checked my patterns against https://grokdebug.herokuapp.com/ and they work. It's something to do with the way I am testing.