Permalink
Browse files

allow for log lines with and without the db time

  • Loading branch information...
1 parent 430c687 commit ab8c3cca1ba64a18e8ff700f005ef267fa24bf35 @garethr committed Aug 18, 2012
Showing with 15 additions and 1 deletion.
  1. +1 −1 patterns/lograge
  2. +14 −0 spec/lograge_spec.rb
View
2 patterns/lograge
@@ -1 +1 @@
-LOGRAGE %{WORD:method}%{SPACE}%{DATA}%{SPACE}action=%{WORD:controller}#%{WORD:action}%{SPACE}status=%{INT:status}%{SPACE}duration=%{NUMBER:duration}%{SPACE}view=%{NUMBER:view}%{GREEDYDATA}
+LOGRAGE %{WORD:method}%{SPACE}%{DATA}%{SPACE}action=%{WORD:controller}#%{WORD:action}%{SPACE}status=%{INT:status}%{SPACE}duration=%{NUMBER:duration}%{SPACE}view=%{NUMBER:view}(%{SPACE}db=%{NUMBER:db})?%{GREEDYDATA}
View
14 spec/lograge_spec.rb
@@ -31,6 +31,20 @@
@match.should have_logstash_field("controller").with_value("jobs")
@match.should have_logstash_field("action").with_value("show")
end
+
+ it "should have the correct value for db time" do
+ @match.should have_logstash_field("db").with_value("15.26")
+ end
+ end
+
+ describe "without the db time" do
+ before do
+ log_line = "GET /jobs/833552.json format=json action=jobs#show status=200 duration=58.33 view=40.43"
+ @match = @grok.match(log_line)
+ end
+ it "should have the correct value for the request view time" do
+ @match.should have_logstash_field("view").with_value("40.43")
+ end
end
describe "with a post request" do

0 comments on commit ab8c3cc

Please sign in to comment.