感谢您的指导,我想在“搜索结果”的“字段”标签中添加其他字段。我看了提取器并进行了相应配置。例如,这是要解析的消息:
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}"]
}
}
在此用例中,如何添加诸如类字段之类的字段?
更新 添加此修订时:
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}}
感谢您的帮助
答案 0 :(得分:0)
您的add_field
配置的语法错误。
应该是:
add_field => { "class" => "%{JAVACLASS}" }