简体   繁体   English

发送到 logstash 的日志的 Grok 模式

[英]Grok pattern for logs sent to logstash

I have haproxy logs that need to be sent to logstash, I am trying to grok the captured request headers.我有需要发送到 logstash 的 haproxy 日志,我正在尝试了解捕获的请求标头。 Can you please suggest the grok pattern?你能推荐一下grok模式吗?

Here is section of log that has the Referrer|User-Agent|X-Forwarded-For|True-Client-IP这是包含引用者|用户代理|X-Forwarded-For|True-Client-IP 的日志部分

{ https://my-dev.mysite.com/|Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36|161.987.654.321, 122.486.243.921, 21.103.137.111|161.987.654.321} { https://my-dev.mysite.com/|Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36|161.987.654.​​2214, 243.921, 21.103.137.111|161.987.654.​​321}

I am new Grok patterns so need your help我是新的 Grok 模式所以需要你的帮助

You can use this one:你可以使用这个:

{%{URI:referrer}\|%{GREEDYDATA:user-agent}\|%{DATA:x-forwarded-for}\|%{IP:ip}}

It will work if you use real IPs.如果您使用真实 IP,它将起作用。

这对我有用...

  {%{DATA:referrer}\|%{GREEDYDATA:user-agent}\|%{DATA:XForwardedFor}\|%{IP:TrueClientIP}}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM