如何在弹性搜索查询中匹配忽略日期和特殊字符的子字符串?

问题描述

我有多个属于这种模式的日志

message: [2021-04-19T20:32:19,044][ERROR][logstash.pipeline ] Exception in pipelineworker,the pipeline stopped processing new events,please check your filter configuration and restart Logstash. {:pipeline_id=>"my_pipeline_id","exception"=>"undefined method `upcase' for nil:NilClass"

我需要运行一个 elasticsearch 查询,该查询在我的所有日​​志中搜索子字符串 undefined method 'upcase'

目前,我的查询是这样设置的:

"input": {
    "search": {
      "request": {
        "search_type": "query_then_fetch","indices": [
          "my-index-name-*"
        ],"rest_total_hits_as_int": true,"body": {
          "query": {
            "bool": {
              "must": [
                {
                  "regexp": {
                    "message": ".*undefined method.*"
                  }
                },{
                  "range": {
                    "@timestamp": {
                      "gte": "Now-1w"
                    }
                  }
                }
              ]
            }
          }
        }
      }
    }
  }

如果我搜索其他术语,我会得到想要的结果。但是,我很难匹配通配符或提供正则表达式。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)