在搜索我的已记录事件时,我遇到了瓶颈。我正在使用 elasticsearch 解决方案,filebeat 将日志消息加载到 elasticsearch 中,并使用 Kibana 前端。
目前,我将消息记录到一个名为 message
的字段中,将异常堆栈跟踪(如果存在)记录到 error.message
中。因此,记录的事件片段可能如下所示:
{
"message": "Thrown exception: CustomException (Exception for testing purposes)"
"error" : {
"message" : "com.press.controller.CustomException: Exception for testing purposes\n at
com.press.controller....<you get the idea at this point>"
}
}
当然,还有其他字段(如时间戳等),但这些并不重要。重要的是:
当我搜索时,可以找到我记录的事件。当我搜索时,就无法得到事件了。我需要能够全文检索所有字段。
有没有办法告诉Elasticsearch在字段中启用全文搜索?为什么“message”字段默认启用全文搜索?我的同事都不知道在部署后的控制台上运行任何索引命令,并且我们的权限不允许我或其他团队成员对任何字段运行索引或分析命令。所以必须在配置文件中。
到目前为止,我还没找到解决方法。请指引我正确的方向。
编辑: 字段的配置如下:
我们使用修改过的ECS,并将两个消息声明为
level: core
type: text
在 fields.yml
文件中。
在 filebeat 中,配置片段如下:
filebeat.inputs:
- type: log
enabled: true
paths: .....
...
...
processors:
- rename:
fields:
- from: "msg"
to: "message"
- from: "filepath"
to: "log.file.name"
- from: "ex"
to: "error.message"
ignore_missing: true
fail_on_error: true
logging.level: debug
logging.to_files: true
出于安全要求,我无法披露完整的文件。而且,我需要手写所有代码段,所以拼写错误很可能是我的问题。
谢谢。