[英]Can filebeat convert log lines output to json without logstash in pipeline?
我们的Spring Boot Web应用程序(非json)中有标准的日志行。 我们需要集中日志记录并将其作为json进行弹性搜索。
(我听说以后的版本可以做一些转换)
Filebeat可以读取日志行并将其包装为json吗? 我猜它也可以附加一些元数据。 无需解析日志行。
预期输出: {timestamp : "", beat: "", message: "the log line..."}
我没有代码可以显示。
filebeat支持几种输出,包括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"
好吧,它似乎默认情况下会这样做。 这是我在本地尝试读取日志行时的结果。 它完全像我想要的那样包装它。
{
"@timestamp":"2019-06-12T11:11:49.094Z",
"@metadata":{
"beat":"filebeat",
"type":"doc",
"version":"6.2.4"
},
"message":"the log line...",
"source":"/Users/myusername/tmp/hej.log",
"offset":721,
"prospector":{
"type":"log"
},
"beat":{
"name":"my-macbook.local",
"hostname":"my-macbook.local",
"version":"6.2.4"
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.