简体   繁体   English

pgpool日志的Logstash grok模式

[英]Logstash grok pattern for pgpool logs

I have a problem finding a right grok pattern for all my logs in order to parse all of them through logstash. 我在为所有日志找到正确的grok模式以通过logstash解析所有日志时遇到问题。

Example of my logs: 我的日志示例:

1) 2016-04-13 19:55:40: pid 21950: LOG: pool_send_and_wait: Error or notice message from backend: : DB node id: 4 backend pid: 65156 statement: "UPDATE certname......"... (The rest of the log doesn't matter) 1)2016-04-13 19:55:40:pid 21950:日志:pool_send_and_wait:来自后端的错误或通知消息::数据库节点ID:4后端pid:65156语句:“ UPDATE certname ......”。 ..(其余日志无所谓)

2) 2016-04-13 19:55:40: pid 17555: FATAL: failed to read kind from backend 2)2016-04-13 19:55:40:pid 17555:致命:无法从后端读取种类

My grok pattern (which works partially) : 我的grok模式(部分起作用):

grok { match => { "message" => "%{GREEDYDATA:logdate}: pid %{NUMBER:pid}: %{LOGLEVEL:loglevel}: %{GREEDYDATA:logmessage}" } } grok {match => {“ message” =>“%{GREEDYDATA:logdate}:pid%{NUMBER:pid}:%{LOGLEVEL:loglevel}:%{GREEDYDATA:logmessage}”}}

As you can see these are the things I care about: 1) The date of the log 2) The PID 3) The loglevel 4) The message itself 如您所见,这些是我关心的事情:1)日志日期2)PID 3)日志级别4)消息本身

Except from the pattern above I also tried to specify the date using the \\A%{TIMESTAMP_ISO8601:timestamp} pattern (just like the grok debugger suggested me). 除了上面的模式外,我还尝试使用\\ A%{TIMESTAMP_ISO8601:timestamp}模式指定日期(就像grok调试器建议的那样)。

My assumption is that the first log is the kind of my problematic logs because it got the word "log" two times in it, Although in the second time it doesn't appears after a colon (unlike my grok pattern) so I have no idea why it fails the parsing operation. 我的假设是,第一个日志是我遇到问题的日志的一种,因为它在其中两次输入了“ log”一词,尽管第二次它没有出现在冒号后面(与我的grok模式不同),所以我没有了解为什么解析操作失败。

In fact, my logs which doesn't contains the word "log" twice parsed successfully - my pattern works partially. 实际上,两次不包含“ log”一词的日志都已成功解析-我的模式部分起作用。

Thanks :) 谢谢 :)

The trick to making grok patterns is to start at the left, get the first one working, and move slowly to the right until you're done. 制作grok模式的技巧是从左侧开始,使第一个模式起作用,然后缓慢向右移动,直到完成。

Doing that, you would see that it stops working when you add %{LOGLEVEL}. 这样做,您会发现在添加%{LOGLEVEL}时它停止工作。 Why? 为什么? Because "LOG" is not a valid valid for LOGLEVEL. 因为“ LOG”对于LOGLEVEL无效,所以无效。 It's expecting things like DEBUG, etc. Use something like %{WORD} instead and it works fine. 期望像DEBUG之类的东西。改用%{WORD}之类的东西,它可以正常工作。

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

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