2016-09-16 105 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