如何避免弹性搜索/ kibana上的重复结果

问题描述 投票:0回答:1

我有以下查询返回异常和/或错误。事情是它返回相同的结果 - 这是该查询的预期行为。

我怎样才能管理仅返回唯一结果的结果?

这是我的查询:

{
  "query": {
    "bool": {
      "should": [
        { "match": { "message": "error" }},
        { "match": { "message": "exception" }}
      ],
      "must_not": {
        "match": {
          "message": "io.vertx.spi.cluster.zookeeper.ZookeeperClusterManager"
        }
      }
    }
  }
}
elasticsearch kibana elastic-stack
1个回答
0
投票

您需要添加聚合以获取(并计算)唯一的异常/错误。尝试这样的事情:

{
  "query": {
    "bool": {
      "should": [
        { "match": { "message": "error" }},
        { "match": { "message": "exception" }}
      ],
      "must_not": {
        "match": {
          "message": "io.vertx.spi.cluster.zookeeper.ZookeeperClusterManager"
        }
      }
    }
  },
  "aggs" : {
    "errors_exceptions" : {
      "terms" : { "field" : "message" }
    }
  }
}

PS:如果经常这样做,可能会更便宜地预先计算异常的哈希值,例如in your logappender (this is just one example, you can probably find something similar for your use case)Logstash

© www.soinside.com 2019 - 2024. All rights reserved.