elasticsearch - 基于二和条件过滤文本以获取 logstash 配置的 if 条件
问题描述
我有一个日志文件。日志文件包含许多 db-exceptions 。我有兴趣在 ElasticSearch 中使用 logstash 和索引来获取所有异常
例外 :
05-06-19 05:34:42.794 6a5ba226-da6a-469a-8304-2f79f68fdbcd http-bio-8080-exec-8 ERROR c.w.m.n.o.i.o.r.XYZRepo executeMerge 157 Failed while processing deliveryList:[deliveryTO{deliveryNumber=92183914, itemNumber=565683539, asnNumber='0664420512', channelMethod='SSTKU,CROSSU', baseDivisionName='wm', countryCode='US' itemUomCode='null', poInd='r', obsoleteInd=null, processStatus='null', itemQuantity=null, overageItemQuantity=null, availableQuantity=322, whpkQuantity=null, vnpkQuantity=null, unfulfilledQty=null ,newItemQty=null} ] with exception:{} com.a.b.c.exceptions.MyDBException: ExceptionCode-BE-00028
Logstash 过滤器:
filter {
grok{
match => { "message" => "%{TIMESTAMP_ISO8601:Date}%{DATA:corelationid}%{LOGLEVEL:loglevel}%{DATA:javaclass}%{NUMBER:number}%{GREEDYDATA:content}" }
overwrite => ["message"]
}
if ("ERROR" not in [loglevel] and "ExceptionCode-BE-00028" not in [content]) {
drop { }
}
}
Logstash 输出:
output {
stdout {
codec => dots
}
elasticsearch {
index => "db-failure"
}
}
解决方案
推荐阅读
- python - 在 python (2020) 中并行化 for 循环的最佳方法是什么?
- javascript - 使用 Jsoup 登录时如何处理 Input 标签中缺少 name 属性?
- ruby-on-rails - 如何在 WINDOWS 10 上将 rails 从 rails 6 降级到 5.2.3?
- git - 了解 git diff 的作用
- mysql - MySQL timediff 函数没有给出正确的输出
- spring-boot - Springdoc:打开 swagger-ui.html 时得到 404
- list - 颤振:不将数据从函数嵌入到列表
- vue.js - 如何使用赛普拉斯选择 (Vue) v-select 选项?
- javascript - 尝试编写 discord bot 以要求特定命令的特定角色
- postgresql - Docker 错误 - 5432:绑定:地址已在使用中