【发布时间】:2020-04-18 09:01:28
【问题描述】:
我们在 Elasticsearch 中使用管道来模拟 grok 过滤器。 我们遇到以下奇怪的行为。
如果时间戳字段位于消息的开头,则 grok 过滤器不起作用。
## GROK NOT WORK
POST /_ingest/pipeline/_simulate
{
"pipeline": {
"processors": [
{
"grok": {
"field": "message",
"patterns": ["""%{TIMESTAMP_ISO8601:@timestamp} %{IP:client} %{WORD:method} %{URIPATHPARAM:request} %{NUMBER:bytes} %{NUMBER:duration} %{TIMESTAMP_ISO8601:@timestamp}"""]
}
}
]
},
"docs": [
{
"_source": {
"message": "2019-09-29T00:39:02.91ZZ 55.3.244.1 GET /index.html 15824 0.043 "
}
}
]
}
我们有以下错误:
{
"docs" : [
{
"error" : {
"root_cause" : [
{
"type" : "illegal_argument_exception",
"reason" : "Provided Grok expressions do not match field value: [2019-09-29T00:39:02.91ZZ 55.3.244.1 GET /index.html 15824 0.043 ]"
}
],
"type" : "illegal_argument_exception",
"reason" : "Provided Grok expressions do not match field value: [2019-09-29T00:39:02.91ZZ 55.3.244.1 GET /index.html 15824 0.043 ]"
}
}
]
}
在这种格式下,消息末尾的时间戳,grok 过滤器工作正常。
## GROK WORKS FINE
POST /_ingest/pipeline/_simulate
{
"pipeline": {
"processors": [
{
"grok": {
"field": "message",
"patterns": ["""%{IP:client} %{WORD:method} %{URIPATHPARAM:request} %{NUMBER:bytes} %{NUMBER:duration} %{TIMESTAMP_ISO8601:@timestamp}"""]
}
}
]
},
"docs": [
{
"_source": {
"message": "55.3.244.1 GET /index.html 15824 0.043 2019-09-29T00:39:02.91ZZ"
}
}
]
}
提前致谢
【问题讨论】:
-
我觉得很奇怪,您的时间戳末尾有两个
ZZ字符...似乎与 ISO8601 不兼容
标签: elasticsearch grok