Skip to content

Instantly share code, notes, and snippets.

@infinityhacks
Forked from louiszuckerman/gist:3908490
Last active September 16, 2015 04:49
Show Gist options
  • Save infinityhacks/dca0b3a7dafc481667d4 to your computer and use it in GitHub Desktop.
Save infinityhacks/dca0b3a7dafc481667d4 to your computer and use it in GitHub Desktop.
Logstash grok parser for custom varnishncsa log format
I pass these options to the varnishncsa daemon (this line is from my /etc/init.d/varnishncsa)...
DAEMON_OPTS="-a -F "\''%h "%{X-Forwarded-For}i" %u %t "%r" %s %b "%{Referer}i" "%{User-agent}i" %{Varnish:time_firstbyte}x %{Varnish:handling}x'\'" -c -w ${LOGFILE} -D -P $PIDFILE"
I parse that with the following grok pattern...
VARNISHNCSALOG %{IPORHOST:remoteip} %{QUOTEDSTRING:xforwardedfor} %{USER:auth} \[%{HTTPDATE:timestamp}\] "%{WORD:verb} %{NOTSPACE:request} HTTP/%{NUMBER:httpversion}" (?:%{NUMBER:status}|\(null\)) (?:%{NUMBER:bytes}|-) "(?:%{NOTSPACE:referrer}|-)" %{QUOTEDSTRING:agent} %{BASE10NUM:berespms} %{WORD:cache}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment