基于多个条件过滤

时间:2021-01-06 15:35:21

标签: elasticsearch

我正在尝试在 Kibana 中进行一个查询,该查询将返回每个具有特定状态代码的请求,仅当它们不在主机黑名单中时。这是我目前所拥有的:

{
    "size": 0,
    "query": {
        "bool": {
            "filter": [
                {
                    "bool": {
                        "must": [
                            {
                                "range": {
                                    "@timestamp": {
                                        "from": "{{period_end}}||-1h",
                                        "to": "{{period_end}}",
                                        "include_lower": true,
                                        "include_upper": true,
                                        "format": "epoch_millis",
                                        "boost": 1
                                    }
                                }
                            },
                            {
                                "range": {
                                    "statusCode": {
                                        "from": 500,
                                        "to": 599,
                                        "include_lower": true,
                                        "include_upper": true,
                                        "boost": 1
                                    }
                                }
                            },
                            {
                                "bool": {
                                    "must_not": [
                                        {
                                            "term": {
                                                "RequestAddr": {
                                                    "value": "hostA.com",
                                                    "boost": 1
                                                }
                                            }
                                        },
                                        {
                                            "term": {
                                                "RequestAddr": {
                                                    "value": "hostB.com",
                                                    "boost": 1
                                                }
                                            }
                                        },
                                        {
                                            "term": {
                                                "RequestAddr": {
                                                    "value": "hostC.com",
                                                    "boost": 1
                                                }
                                            }
                                        },
                                        {
                                            "term": {
                                                "RequestAddr": {
                                                    "value": "hostD.com",
                                                    "boost": 1
                                                }
                                            }
                                        },
                                        {
                                            "term": {
                                                "RequestAddr": {
                                                    "value": "hostE.com",
                                                    "boost": 1
                                                }
                                            }
                                        },
                                        {
                                            "term": {
                                                "RequestAddr": {
                                                    "value": "hostF.com",
                                                    "boost": 1
                                                }
                                            }
                                        },
                                        {
                                            "term": {
                                                "RequestAddr": {
                                                    "value": "hostG.com",
                                                    "boost": 1
                                                }
                                            }
                                        },
                                        {
                                            "term": {
                                                "RequestAddr": {
                                                    "value": "hostH.com",
                                                    "boost": 1
                                                }
                                            }
                                        }
                                    ]
                                }
                            }
                        ]
                    }
                }
            ],
            "adjust_pure_negative": true,
            "boost": 1
        }
    },
    "aggregations": {}
}

到目前为止我对此的理解是,它通过过滤器:

  • 日志条目最多 1 小时前
  • 状态代码介于 500 和 599 之间
  • RequestAddr 不是 hostA...H.com

然而,这会根据忽略第三个过滤器的两个过滤器返回每个日志条目。我错过了什么?

0 个答案:

没有答案