使用 add_field 参数有两种需求:
1. 直接加入到 event 的 hash 顶级对象中
add_field => { "my_field_one" => "one" }
那么,结果会类似:
{ "公司名称" => "xxx", "BUG_ID" => 1234, "VIP_Level" => "核心VIP", "my_field_one" => "one", }
2. 加入到 event 的某个 tag 中
add_field => { "[其它][tag1]" => "one" "[其它][tag2]" => "two" }
那么,结果会类似:
{ "公司名称" => "xxx", "BUG_ID" => 1234, "VIP_Level" => "核心VIP", "其它" => { "tag1" => "one", "tag2" => "two" } }
3. 由于 add_field 参数要求格式为 hash,我尝试如下用法结果发现满足不了需求。( ╯□╰ )为嘛???
add_field => { #方法一: "其它" => { "tag1" => "one", "tag2" => "two" } #方法二:和logstash中一贯用法一样,不加逗号 "其它2" => { "tag1" => "one" "tag2" => "two" } #方法三:写在一行上 "其它2" => {"tag1" => "one", "tag2" => "two" } } #方法四:先执行 add_tag 再执行 add_field。这样为嘛会是数组???add_tag => "其它" add_field = { "其它" => { "tag1" => "one" "tag2" => "two" } }
时间: 2024-10-10 05:42:16