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?
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742347982a4426933.html
评论列表(0条)