2016-09-16 104 views
0

我需要你的帮助。 我有fluentd配置为尾部模式将我的日志发送到elasticsearch群集。 我使用的是regex来解析每个日志行,但对于一些字段,我需要将metricValue转换为integer。我尝试了一些东西,但没有工作。fluentd转换字段为整数

这里是我的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>,... 

我想在发送到elasticsearch之前将字段metricValue转换为整数。

谢谢你的任何想法。

C.C.

回答

1

您必须将这些字段(types <field_name_1>:<type_name_1>,<field_name_2>:<type_name_2>,...)放入您的案例的source部分。 如果您使用parser插件,则必须将其插入filter部分(这里是example