我们的Spring Boot Web应用程序(非json)中有标准的日志行。
我们需要集中日志记录并将其作为json进行 flex 搜索。
(我听说以后的版本可以做一些转换)
Filebeat可以读取日志行并将其包装为json吗?我猜它也可以附加一些元数据。无需解析日志行。
预期产量:{timestamp : "", beat: "", message: "the log line..."}
我没有代码可以显示。
最佳答案
filebeat支持several outputs包括Elastic Search。
配置文件filebeat.yml如下所示:
# filebeat options: https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-reference-yml.html
filebeat.inputs:
- type: log
enabled: true
paths:
- /var/log/../file.err.log
processors:
- drop_fields:
# Prevent fail of Logstash (https://www.elastic.co/guide/en/beats/libbeat/current/breaking-changes-6.3.html#custom-template-non-versioned-indices)
fields: ["host"]
- dissect:
# tokenizer syntax: https://www.elastic.co/guide/en/logstash/current/plugins-filters-dissect.html.
tokenizer: "%{} %{} [%{}] {%{}} <%{level}> %{message}"
field: "message"
target_prefix: "spring boot"
fields:
log_type: spring_boot
output.elasticsearch:
hosts: ["https://localhost:9200"]
username: "filebeat_internal"
password: "YOUR_PASSWORD"
关于elasticsearch - Filebeat可以在管道中没有logstash的情况下将日志行输出转换为json吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56556506/