流利地将字段转换为整数
fluentd convert field to integer
我需要你的帮助。
我在尾部模式下配置了 fluentd
以将我的日志发送到 elasticsearch
集群。
我正在使用 regex
来解析每个日志行,但对于某些字段,我需要将 metricValue
转换为 integer
。我尝试了一些方法但没有用。
这是我的 fluentd conf 文件:
<source>
@type tail
path /tmp/application.log
pos_file /tmp/access.log.pos
format multi_format
tag first.log
<pattern>
format /(?<app>.*)\((?<instance>.*)\) CID\((?<correlationId>.*)\) (?<level>.*) \[(?<timestamp>.*)\] \[(?<Thread>.*)\] (?<class>.*) - \[Provider:(?<providerName>.*),Curef:(?<cuRef>.*),Operation:(?<operation>.*),Reference:(?<reference>.*),Idx:(?<idx>.*)\]/
</pattern>
<pattern>
format /(?<app>.*)\((?<instance>.*)\) CID\((?<correlationId>.*)\) (?<level>.*) \[(?<timestamp>.*)\] \[(?<Thread>.*)\] (?<class>.*) - (?<body>.*)/
</pattern>
</source>
<match *.log>
@type copy
<store>
@type stdout
</store>
<store>
@type elasticsearch
host localhost
port 9200
logstash_format true
logstash_prefix fluentd-log
flush_interval 10s
</store>
</match>
我在 fluend 文档中找到了语法但没有用(我不知道把这些行放在哪里)
types <field_name_1>:<type_name_1>,<field_name_2>:<type_name_2>,...
我想在将字段 metricValue 发送到 elasticsearch
之前将其转换为整数。
感谢任何想法。
C.C.
您必须将这些字段 (types <field_name_1>:<type_name_1>,<field_name_2>:<type_name_2>,...
) 放入案例中的 source
部分。
如果你使用 parser plugin, you have to insert it inside the filter
section (here is an )
我需要你的帮助。
我在尾部模式下配置了 fluentd
以将我的日志发送到 elasticsearch
集群。
我正在使用 regex
来解析每个日志行,但对于某些字段,我需要将 metricValue
转换为 integer
。我尝试了一些方法但没有用。
这是我的 fluentd conf 文件:
<source>
@type tail
path /tmp/application.log
pos_file /tmp/access.log.pos
format multi_format
tag first.log
<pattern>
format /(?<app>.*)\((?<instance>.*)\) CID\((?<correlationId>.*)\) (?<level>.*) \[(?<timestamp>.*)\] \[(?<Thread>.*)\] (?<class>.*) - \[Provider:(?<providerName>.*),Curef:(?<cuRef>.*),Operation:(?<operation>.*),Reference:(?<reference>.*),Idx:(?<idx>.*)\]/
</pattern>
<pattern>
format /(?<app>.*)\((?<instance>.*)\) CID\((?<correlationId>.*)\) (?<level>.*) \[(?<timestamp>.*)\] \[(?<Thread>.*)\] (?<class>.*) - (?<body>.*)/
</pattern>
</source>
<match *.log>
@type copy
<store>
@type stdout
</store>
<store>
@type elasticsearch
host localhost
port 9200
logstash_format true
logstash_prefix fluentd-log
flush_interval 10s
</store>
</match>
我在 fluend 文档中找到了语法但没有用(我不知道把这些行放在哪里)
types <field_name_1>:<type_name_1>,<field_name_2>:<type_name_2>,...
我想在将字段 metricValue 发送到 elasticsearch
之前将其转换为整数。
感谢任何想法。
C.C.
您必须将这些字段 (types <field_name_1>:<type_name_1>,<field_name_2>:<type_name_2>,...
) 放入案例中的 source
部分。
如果你使用 parser plugin, you have to insert it inside the filter
section (here is an