简体   繁体   English

如何使用自定义Logstash grok模式?

[英]How to use custom Logstash grok patterns?

I'm using Logstash on Debian 9 and I want to use custom grok patterns. 我在Debian 9上使用Logstash,我想使用自定义的grok模式。 So I've added them to directory /usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-patterns-core-4.1.2/patterns - created new files and also modified existing (grok-patterns, auth, etc.). 所以我将它们添加到目录/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-patterns-core-4.1.2/patterns创建了新文件并修改了现有文件(grok-patterns ,身份验证等)。

Problem is that my changes in original files was overwritten and lost (at 02:35 am 12.6.2018). 问题是我对原始文件的更改被覆盖并丢失(在2018年1月26日上午02:35)。

Is there some automatic updating of logstash-patterns-core ? 是否有一些logstash-patterns-core自动更新? How can I change existing grok patterns? 我该如何更改现有的grok模式?

Unfortunately, the directory structure where you modified the file is for binaries. 不幸的是,修改文件的目录结构是二进制文件。 You don't need to modify any files at all to add custom patterns. 您完全不需要修改任何文件即可添加自定义模式。 Please have a look at Logstash Directory layout here . 请在此处查看Logstash目录的布局

Instead of modifying or adding files under a binary path, you can create a new directory under /etc/logstash , call it a pattern and add your custom patterns there. 您可以在/etc/logstash下创建一个新目录,而不是在二进制路径下修改或添加文件,将其称为pattern并在其中添加自定义模式。

You can then import custom patterns as follows, 然后,您可以按以下方式导入自定义模式,

filter {
    grok {
        patterns_dir => "../patterns"
        match =>["message", "%{ANYPATTERN}" ]
    }
}

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

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