【发布时间】:2019-06-14 23:41:34
【问题描述】:
问题:
我们的日志数据有 27-34 百万个 /event-heartbeat 条目。 我需要过滤掉这些条目,以便在 Kibana 中查看可行的日志消息。
使用带有通配符的 Kibana 过滤器不起作用。因此,我认为我必须在 6.4.2 版本的 Elasticsearch 中编写 QueryDSL 才能过滤掉事件心跳。
我一直在寻找,但找不到任何关于如何进行反模式匹配的好的解释,以便搜索消息中没有 /event-heartbeat 的所有条目。
这是日志消息:
@timestamp:
June 14th 2019, 12:39:09.225
host.name:
iislogs-production
source:
C:\inetpub\logs\LogFiles\W3SVC5\u_ex19061412.log
offset:
83,944,181
message:
2019-06-14 19:39:06 0.0.0.0 GET /event-heartbeat id=Budrug2UDw 443 - 0.0.0.0 - - 200 0 0 31
prospector.type:
log
input.type:
log
beat.name:
iislogs-production
beat.hostname:
MYHOSTNAME
beat.version:
6.4.2
_id:
yg6AV2sB0_n
_type:
doc
_index:
iislogs-production-6.4.2-2019.06.14
_score:
-
Message 是一个关键字字段,因此我可以对其进行轻松的脚本编写。
我用过 Lucene 语法
NOT message: "*/event-heartbeat*"
This is the anti pattern the kibana filter generates.
{
"query": {
"bool": {
"should": [
{
"match_phrase": {
"message": "*event-heartbeat*"
}
}
],
"minimum_should_match": 1
}
}
}
我已经尝试了以下由 huglap 提出的解决方案。我还根据他的评论调整了我的查询,并尝试了两种方法。我用词而不是匹配来调整它,并尝试了两种方式,因为从技术上讲,该字段是一个关键字,所以我可以对其进行轻松的脚本编写。该查询仍会返回事件心跳日志条目。
这是我从以下建议的解决方案中尝试的两个查询:
GET /iislogs-production-*/_search
{
"query":{
"bool":{
"must":{
"match_all":{
}
},
"filter":{
"bool":{
"must_not":[
{
"term":{
"message.whitespace":"event-heartbeat"
}
}
]
}
}
}
}
}
GET /iislogs-production-*/_search
{
"query":{
"bool":{
"must":{
"match_all":{
}
},
"filter":{
"bool":{
"must_not":[
{
"match":{
"message.whitespace":"event-heartbeat"
}
}
]
}
}
}
}
}
索引映射: https://gist.github.com/zukeru/907a9b2fa2f0d6f91a532b0865131988
【问题讨论】:
标签: elasticsearch kibana