admin管理员组文章数量:1332890
I am trying to use the record_transformer filter plugin in Fluentd to modify log records. Specifically, I want to include a field where the value is determined by a multiline Ruby if-else statement. However, it seems that the block does not support multiline code or throws errors when I try to format my logic in multiple lines for readability.
For example, I tried the following configuration:
<filter my_tag>
@type record_transformer
enable_ruby
<record>
new_field ${if record["key"] == "value1"
"output1"
elsif record["key"] == "value2"
"output2"
else
"default_output"
end}
</record>
</filter>
This gives me an error.
<record>
new_field ${if record["key"] == "value1"; "output1"; elsif record["key"] == "value2"; "output2"; else; "default_output"; end}
</record>
This single-line format is hard to read and maintain when the logic becomes more complex.
- Is there a workaround to make multiline logic work in ?
- Should I use a different plugin for this type of transformation? If so, what would be a good alternative?
版权声明:本文标题:How to write multiline if-else statements inside <record> in Fluentd record_transformer? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742347982a2457911.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论