我在 filebeat.yml 中使用 Filebeat 多行模式,它从单个文件中获取输入,如下所示:
2016-10-06 14:36:00.419 DEBUG 29695 --- [XNIO-2 task-2] c.a.a.s.endpoint.endone.server : requestStartIdentifier: Identifier
2016-10-06 14:36:00.419 DEBUG 29695 --- [XNIO-2 task-2] c.a.a.s.endpoint.endone.server : requestUri:
2016-10-06 14:36:00.420 DEBUG 29695 --- [XNIO-2 task-2] c.a.a.s.endpoint.endone.server : HttpServletRequest:
ContentType: text/xml; charset=utf-8
ContextPath:
LocalAddr:
LocalName:
PathInfo:
PathTranslated:
QueryString:
RequestURI:
RequestURL:
RemoteHost:
ServletPath:
Header: Host:
Header: Content-Length:
Header: Accept-Encoding:
Header: SOAPAction: ""
Header: User-Agent: Apache-HttpClient/4.2.1
Header: Content-Type: text/xml; charset=utf-8
Header: Connection: Keep-Alive
Header: Accept: text/xml
2016-10-06 14:36:00.420 DEBUG 29695 --- [XNIO-2 task-2] c.a.a.s.endpoint.endone.server : uri: , request:
<env:Envelope></env:Envelope>
2016-10-06 14:36:00.419 DEBUG 29695 --- [XNIO-2 task-2] c.a.a.s.endpoint.endone.server : requestStartIdentifier: Identifier
2016-10-06 14:36:00.419 DEBUG 29695 --- [XNIO-2 task-2] c.a.a.s.endpoint.endone.server : requestUri:
2016-10-06 14:36:00.420 DEBUG 29695 --- [XNIO-2 task-2] c.a.a.s.endpoint.endone.server : HttpServletRequest:
ContentType: text/xml; charset=utf-8
ContextPath:
LocalAddr:
LocalName:
PathInfo:
PathTranslated:
QueryString:
RequestURI:
RequestURL:
RemoteHost:
ServletPath:
Header: Host:
Header: Content-Length:
Header: Accept-Encoding:
Header: SOAPAction: ""
Header: User-Agent: Apache-HttpClient/4.2.1
Header: Content-Type: text/xml; charset=utf-8
Header: Connection: Keep-Alive
Header: Accept: text/xml
2016-10-06 14:36:00.420 DEBUG 29695 --- [XNIO-2 task-2] c.a.a.s.endpoint.endone.server : uri: , request:
<env:Envelope></env:Envelope>
文件节拍.yml
multiline:
pattern: Identifier
negate: true
match: after
我使用上面的配置来匹配行中的“标识符”。输出应如所愿
event -1 :
2016-10-06 14:36:00.419 DEBUG 29695 --- [XNIO-2 task-2] c.a.a.s.endpoint.endone.server : requestStartIdentifier: Identifier
2016-10-06 14:36:00.419 DEBUG 29695 --- [XNIO-2 task-2] c.a.a.s.endpoint.endone.server : requestUri:
2016-10-06 14:36:00.420 DEBUG 29695 --- [XNIO-2 task-2] c.a.a.s.endpoint.endone.server : HttpServletRequest:
ContentType: text/xml; charset=utf-8
ContextPath:
LocalAddr:
LocalName:
PathInfo:
PathTranslated:
QueryString:
RequestURI:
RequestURL:
RemoteHost:
ServletPath:
Header: Host:
Header: Content-Length:
Header: Accept-Encoding:
Header: SOAPAction: ""
Header: User-Agent: Apache-HttpClient/4.2.1
Header: Content-Type: text/xml; charset=utf-8
Header: Connection: Keep-Alive
Header: Accept: text/xml
2016-10-06 14:36:00.420 DEBUG 29695 --- [XNIO-2 task-2] c.a.a.s.endpoint.endone.server : uri: , request:
<env:Envelope></env:Envelope>
event -2 :
2016-10-06 14:36:00.419 DEBUG 29695 --- [XNIO-2 task-2] c.a.a.s.endpoint.endone.server : requestStartIdentifier: Identifier
2016-10-06 14:36:00.419 DEBUG 29695 --- [XNIO-2 task-2] c.a.a.s.endpoint.endone.server : requestUri:
2016-10-06 14:36:00.420 DEBUG 29695 --- [XNIO-2 task-2] c.a.a.s.endpoint.endone.server : HttpServletRequest:
ContentType: text/xml; charset=utf-8
ContextPath:
LocalAddr:
LocalName:
PathInfo:
PathTranslated:
QueryString:
RequestURI:
RequestURL:
RemoteHost:
ServletPath:
Header: Host:
Header: Content-Length:
Header: Accept-Encoding:
Header: SOAPAction: ""
Header: User-Agent: Apache-HttpClient/4.2.1
Header: Content-Type: text/xml; charset=utf-8
Header: Connection: Keep-Alive
Header: Accept: text/xml
2016-10-06 14:36:00.420 DEBUG 29695 --- [XNIO-2 task-2] c.a.a.s.endpoint.endone.server : uri: , request:
<env:Envelope></env:Envelope>