【问题标题】:How to add/remove additional fields in Graylog如何在 Graylog 中添加/删除附加字段
【发布时间】:2019-03-13 23:58:35
【问题描述】:

感谢您的指导,我想在搜索结果的字段选项卡中添加其他字段。我已经查看了提取器并进行了相应的配置。例如,这是要解析的消息:

2019-03-12 10:15:51 [https-jsse-nio-8020-exec-10] INFO : ASCPA7C500611418  ab.bc.cde.efg.common.rest.endpoints.component.filter End

我添加了 JAVACLASS 模式:

(?:[a-zA-Z$_][a-zA-Z$_0-9]*\.)*[a-zA-Z$_][a-zA-Z$_0-9]*

之后,我配置了提取器并包含以下模式:

%{TIMESTAMP_ISO8601}(?:%{SPACE})%{SYSLOG5424SD}(?:%{SPACE})%{LOGLEVEL}*(?:%{SPACE}):*(?:%{SPACE})%{WORD}*(?:%{SPACE})%{JAVACLASS:class}%{GREEDYDATA}

这提供了以下提取器预览:

WORD
ASCPA7C500611418
TIMESTAMP_ISO8601
2019-03-12 10:15:51
MONTHNUM
03
HOUR
[10, null]
message
End
SPACE
[ , , , , ]
YEAR
2019
DATA
https-jsse-nio-8020-exec-10
MINUTE
[15, null]
SECOND
51
LOGLEVEL
INFO
JAVACLASS
ab.bc.cde.efg.common.rest.endpoints.component.filter
MONTHDAY
12
SYSLOG5424SD
[https-jsse-nio-8020-exec-10]

Java 类已正确解析,但在搜索结果中,所有字段都显示在“字段”选项卡下:

但是,我只想在列表中添加“类”字段。我怎样才能摆脱其他领域?我已经尝试只保留 JAVACLASS,但我没有得到该类的适当值。

我还删除了提取器,并在 logstash.conf 的过滤器中添加了以下内容:

 filter {
        grok {
            match => {
                "message" => "%{TIMESTAMP_ISO8601}(?:%{SPACE})%{SYSLOG5424SD}(?:%{SPACE})%{LOGLEVEL}*(?:%{SPACE}):*(?:%{SPACE})%{WORD}*(?:%{SPACE})%{JAVACLASS:class}%{GREEDYDATA:message}"            
            }
            add_field => [ "class","%{JAVACLASS}"]

        }        
}

但我没有在 Graylog 中获得名为 class 的字段:

如何在此用例中添加字段,例如类字段?

更新 添加此修复程序时:

add_field => { "class" => "%{JAVACLASS}" }

获取以下logstash输出:

[2019-03-14T09:52:58,025][DEBUG][logstash.outputs.gelf    ] Sending GELF event {:event=>{"short_message"=>["2019-03-07 06:06:46 [localhost-startStop-1] DEBUG:   org.springframework.beans.factory.support.DefaultListableBeanFactory Autowiring by type from bean name 'serviceClientMapper' via property 'sqlSessionFactory' to bean named 'sqlSessionFactory'", " Autowiring by type from bean name 'serviceClientMapper' via property 'sqlSessionFactory' to bean named 'sqlSessionFactory'"], "full_message"=>"2019-03-07 06:06:46 [localhost-startStop-1] DEBUG:   org.springframework.beans.factory.support.DefaultListableBeanFactory Autowiring by type from bean name 'serviceClientMapper' via property 'sqlSessionFactory' to bean named 'sqlSessionFactory', Autowiring by type from bean name 'serviceClientMapper' via property 'sqlSessionFactory' to bean named 'sqlSessionFactory'", "host"=>"{\"os\":{\"name\":\"CentOS Linux\",\"version\":\"7 (Core)\",\"codename\":\"Core\"},\"name\":\"d1tomcat\"}", "_log_file"=>{"path"=>"/apps/logs/ABC/abc-rest-api/abc-rest-api.log"}, "_source"=>"/apps/logs/ABC/abc-rest-api/abc-rest-api.log", "_meta_cloud"=>{}, "_tags"=>"beats_input_codec_plain_applied", **"_class"=>"org.springframework.beans.factory.support.DefaultListableBeanFactory, %{JAVACLASS}"**, "_beat_name"=>"d1tomcat", "_beat_hostname"=>"d1tomcat", "_component"=>"component", "level"=>6}}

感谢您的帮助

【问题讨论】:

    标签: logstash logstash-grok graylog3


    【解决方案1】:

    您的add_field 配置语法错误。

    应该是:

    add_field => { "class" => "%{JAVACLASS}" }
    

    【讨论】:

    • 感谢 Leandro,我已添加此更改,但我继续没有在 Graylog 和 Kibana 中获得该字段。我在帖子中添加了一个更新,显示了logstash中的输出。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-30
    • 1970-01-01
    • 2018-11-09
    • 2020-05-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多