Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Logging FluentD:record_transformer条件语句_Logging_Fluent_Fluentd - Fatal编程技术网

Logging FluentD:record_transformer条件语句

Logging FluentD:record_transformer条件语句,logging,fluent,fluentd,Logging,Fluent,Fluentd,如何将条件if-else语句放入fluentdrecord\u transformer,并将输出添加到列中 例如: @型记录变压器 启用\u ruby true 自动类型转换为真 NormalizedFileInByte${a=1024;如果记录[DataMetricIn]=“GB”;记录[“FileInByte]”。到\u f*a.to\u f;否则;记录[“FileInByte]”。到\u f;结束;} 在上面的示例中,我添加了一条if-else语句,并在现有日志中添加了一个新列Norm

如何将条件if-else语句放入fluentd
record\u transformer
,并将输出添加到列中

例如:


@型记录变压器
启用\u ruby true
自动类型转换为真
NormalizedFileInByte${a=1024;如果记录[DataMetricIn]=“GB”;记录[“FileInByte]”。到\u f*a.to\u f;否则;记录[“FileInByte]”。到\u f;结束;}
在上面的示例中,我添加了一条if-else语句,并在现有日志中添加了一个新列
NormalizedFileInByte
。但它是错误的。

这对我来说很有效:

NormalizedFileInByte ${if record["message"].split(" ")[2].split(",")[0] == "PM"; record["message"].split(" ")[2].split(",")[0] ;end;
这对我很有用:

NormalizedFileInByte ${if record["message"].split(" ")[2].split(",")[0] == "PM"; record["message"].split(" ")[2].split(",")[0] ;end;

我还尝试了一种不同的语法,结果NormalizedFileInByte被创建,但总是有一个值为零。更改的语法:NormalizedFileInByte${a=“1024”;如果$DataMetricIn==“GB”,则为$FileInByte.to\f*a.to\f else$FileInByte.to\f end}我还尝试了不同的语法,结果是创建了NormalizedFileInByte,但始终具有零值。更改的语法:NormalizedFileInByte${a=“1024”;如果$DataMetricIn==“GB”,则$FileInByte.to\u f*a.to\u f else$FileInByte.to\u f end}