用于跟踪IIS日志的Grok模式将是什么?

时间:2018-09-17 15:11:26

标签: logstash-grok logstash-configuration grok logstash-file opengrok

我有以下IIS服务器日志:

2018-09-16 04:11:47 W3SVC10 webserver 107.6.166.194 POST /api/uploadjsontrip - 443 - 203.77.177.176 HTTP/1.1 Java/1.8.0_45 - - vehicletrack.biz 200 0 0 506 872 508

数据描述:

date time s-sitename s-computername s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs-version cs(User-Agent) cs(Cookie) cs(Referer) cs-host sc-status sc-substatus sc-win32-status sc-bytes cs-bytes time-taken

如何编写Grok模式以提取每一列的值?

我尝试关注,但没有成功。

%{TIMESTAMP_ISO8601:timestamp} %{NOTSPACE:s-sitename} %{WORD:cs-method} %{URIPATH:cs-uri-stem} %{NOTSPACE:cs-uri-query} %{NUMBER:s-port} %{NOTSPACE:cs-username} %{IPORHOST:c-ip} %{NOTSPACE:cs(User-Agent)} %{NOTSPACE:cs(Cookie)} %{NOTSPACE:cs(Referer)} %{NOTSPACE:cs-host} %{NUMBER:sc-status:int} %{NUMBER:sc-substatus:int} %{NUMBER:sc-win32-status:int} %{NUMBER:sc-bytes:int} %{NUMBER:cs-bytes:int} %{NUMBER:time-taken:int}" ,
"message", "%{TIMESTAMP_ISO8601:timestamp} %{IPORHOST:s-sitename} %{WORD:cs-method} %{URIPATH:cs-uri-stem} %{NOTSPACE:cs-uri-query} %{NUMBER:s-port} %{NOTSPACE:cs-username} %{IPORHOST:c-ip} %{NOTSPACE:cs(User-Agent)} %{NOTSPACE:cs(Referer)} %{NUMBER:response:int} %{NUMBER:sc-substatus:int} %{NUMBER:sc-substatus:int} %{NUMBER:time-taken:int}" ,
"message", "%{TIMESTAMP_ISO8601:timestamp} %{WORD:cs-method} %{URIPATH:cs-uri-stem} %{NOTSPACE:cs-post-data} %{NUMBER:s-port} %{IPORHOST:c-ip} HTTP/%{NUMBER:c-http-version} %{NOTSPACE:cs(User-Agent)} %{NOTSPACE:cs(Cookie)} %{NOTSPACE:cs(Referer)} %{NOTSPACE:cs-host} %{NUMBER:sc-status:int} %{NUMBER:sc-bytes:int} %{NUMBER:cs-bytes:int} %{NUMBER:time-taken:int}

请帮助我。

谢谢。

1 个答案:

答案 0 :(得分:0)

这将对您提供的grok行有效。但是根据数据,它可能在用户代理和cookie附近失败。

%{TIMESTAMP_ISO8601:timestamp} %{NOTSPACE:s_sitename} %{WORD:s_computername} %{IPV4:s_ip} %{WORD:cs_method} %{URIPATH:cs_uri_stem} %{DATA:cs_uri_query} %{NUMBER:s_port} - %{IPV4:cs_ip} HTTP/%{NUMBER:cs_vserion} %{NOTSPACE:cs_user_agent} %{NOTSPACE:cs_cookie} (-|%{URI:cs_refrer}) %{IPORHOST:cs_host} %{INT:sc_status} %{INT:sc_substatus} %{INT:sc_win32-status} %{INT:sc_bytes} %{INT:cs_bytes} %{INT:time_taken}

此外,您可能会发现此工具更容易进行grok测试和调试https://grokdebug.herokuapp.com/

相关问题