这是我使用grok和elasticsearch的第一次经历。我正在尝试编写一个grok文件来解析以下行。
2017-07-25 10:48:23,477 [[api-my-app-v1-20.0.0].apiHttpListenerConfig.worker.58] INFO esb.api-my-app-v1.get-blah.http.response - transactionID=f61b8053-70d2-11e7-b274-3639cc5335d0 creationTime=2017-07-25T10:48:23.254+10:00 txnState=END timeTaken=11
到目前为止,我已写过这个小伙伴......
%{TIMESTAMP_ISO8601:timestamp}\s+%{DATA:thread}\s+%{LOGLEVEL:loglevel}\s+%{JAVACLASS:category}\s+-\s+%{GREEDYDATA:msgbody}
它让我回来了......
{
"timestamp": [
[
"2017-07-25 10:48:23,477"
]
],
"YEAR": [
[
"2017"
]
],
"MONTHNUM": [
[
"07"
]
],
"MONTHDAY": [
[
"25"
]
],
"HOUR": [
[
"10",
null
]
],
"MINUTE": [
[
"48",
null
]
],
"SECOND": [
[
"23,477"
]
],
"ISO8601_TIMEZONE": [
[
null
]
],
"thread": [
[
"[[api-my-app-v1-20.0.0].apiHttpListenerConfig.worker.58]"
]
],
"loglevel": [
[
"INFO"
]
],
"category": [
[
"esb.api-my-app-v1.get-blah.http.response"
]
],
"msgbody": [
[
"transactionID=f61b8053-70d2-11e7-b274-3639cc5335d0 creationTime=2017-07-25T10:48:23.254+10:00 txnState=END timeTaken=11"
]
]
}
这几乎是我想要的。如何将msgbody从当前结果拆分为键值对?
感谢
答案 0 :(得分:3)
使用kv过滤器:
msgbody
您的结果中的{{1}}字段中包含密钥对值。如果键改变,你也不必改变你的格鲁克模式。