0

我需要使用 Geo IP 过滤以下 apache vhost 日志格式。这样 grok 才能理解并顺利工作。

准确的日志格式:

LogFormat "%V:%p %h %l %u %t \"%r\" %>s %O %T %D \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined_custom

您会看到 %T 和 %D 标志在这里是多余的。

信息:

sub1.example.com:443 1.9.202.41 - - [03/Jun/2016:06:58:17 +0000] "GET /notifications/pendingCount HTTP/1.1" 200 591 0 32165 "https://sub1.example.com/path/index?var=871190" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"

有什么建议么?

4

2 回答 2

1

你也可以这样做:

match => { "message" => "%{HOSTNAME:vhost}\:%{NUMBER:port} %{COMBINEDAPACHELOG}"}

根据Rene 的博客

于 2016-09-03T11:16:41.963 回答
0

好的,经过多次测试,我找到了解决方案。它应该是这样的:

grok {                                                                                           
      match => { "message" => "%{IPORHOST:vhost}:%{POSINT:port} %{IPORHOST:clientip} %{USER:ident} %{USER:auth} \[%{HTTPDATE:timestamp}\] \"(?:%{WORD:verb} %{NOTSPACE:request}(?: HTTP/%{NUMBER:httpversion})?|%{DATA:rawrequest})\" %{NUMBER:response} %{NUMBER:bytes} %{NUMBER:seconds} %{NUMBER:microseconds} %{QS:referrer} %{QS:agent}" }
}
于 2016-06-03T08:32:49.233 回答