logstash - logstash - output single event into multiple line output file
问题描述
I have a jdbc input with a select statement. each row in the restult set has 3 columns. c1
, c2
, c3
. the event emitted has the following structure:
{"c1":"v1", "c2":"v2", "c3":"v3", "file_name":"tmp.csv"}
I want to output the values in a file in the following manner:
output file:
v1
v2
v3
this is the output configuration:
file {
path => "/tmp/%{file_name}"
codec => plain { format => "%{c1}\n%{c2}\n%{c3}" }
write_behavior => "overwrite"
flush_interval => 0
}
but what is generated is
outputfile:
v1\nv2\nv3
is the plain codec plugin not the one i need? is there any other codec plugin for the output file plugin that i can use? or is the only option i have is to write my own plugin?
Thanks!
解决方案
聚会有点晚了,但也许这对其他人有帮助。虽然它看起来很时髦,但您应该能够在格式字符串中简单地按 Enter (使用line
编解码器)。
file {
path => "/tmp/%{file_name}"
codec => line {
format => "%{c1}
%{c2}
%{c3}"
}
write_behavior => "overwrite"
flush_interval => 0
}
不是最漂亮的方法,但它有效。不确定是否有更好的方法。
推荐阅读
- java - SVG 或 VectorDrawable 运行时构建器
- asp.net-core - ASP.Net 核心和 ProcessStartInfo
- android - wifi断开后我的重复警报不起作用
- google-app-engine - 使用 TCP 从 App Engine 自定义环境连接到 Google Cloud SQL 时出错
- ios - 从数组中删除特定值,而不是使用索引路径删除
- html - 使用 display flex 和按钮下的显示块按钮
- javascript - 在 Web 浏览器中多次接收 FCM 推送通知
- python-3.x - 如何查找内部列表中的最后一个值在python的嵌套列表中重复了多少次?
- powershell - 用 Powershell 减去日期
- python - 在 python 中解析 csv 并在其他 csv 中写入,是的选择存在,如果选择不存在,则没有