[英]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.