微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

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

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

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 举报,一经查实,本站将立刻删除。