filebeat 可以在管道中没有 logstash 的情况下将日志行输出转换为 json 吗?
Can filebeat convert log lines output to json without logstash in pipeline?
我们的 Spring 引导 Web 应用程序(非 json)中有标准日志行。
我们需要集中我们的日志并将它们作为 json 发送到弹性搜索。
(听说后面的版本可以做一些改造)
Filebeat 可以读取日志行并将它们包装为 json 吗?我想它也可以附加一些元数据。无需解析日志行。
预期输出:
{timestamp : "", beat: "", message: "the log line..."}
不幸的是我没有代码可以显示。
filebeat 支持 several outputs including 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"
}
}
我们的 Spring 引导 Web 应用程序(非 json)中有标准日志行。 我们需要集中我们的日志并将它们作为 json 发送到弹性搜索。
(听说后面的版本可以做一些改造)
Filebeat 可以读取日志行并将它们包装为 json 吗?我想它也可以附加一些元数据。无需解析日志行。
预期输出:
{timestamp : "", beat: "", message: "the log line..."}
不幸的是我没有代码可以显示。
filebeat 支持 several outputs including 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"
}
}