How to put conditional if else statements in fluentd record_transformer and add output to column.
eg:
<filter nifi.*>
@type record_transformer
enable_ruby true
auto_typecast true
<record>
NormalizedFileInByte ${a=1024;if record[DataMetricIn]=="GB";record["FilesInByte"].to_f*a.to_f;else;record["FilesInByte"].to_f;end;}
</record>
</filter>
I have put an if else statement and added a new column NormalizedFileInByte to existing log in the above example. But it errors.
this worked for me:
NormalizedFileInByte ${if record["message"].split(" ")[2].split(",")[0] == "PM"; record["message"].split(" ")[2].split(",")[0] ;end;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With