【问题标题】:fluentd convert field to integerfluentd 将字段转换为整数
【发布时间】:2016-09-16 07:11:48
【问题描述】:

我需要你的帮助。 我将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>

我在流利的文档中找到了语法但不起作用(而且我不知道将这些行放在哪里)

types <field_name_1>:<type_name_1>,<field_name_2>:<type_name_2>,...

我想将字段 metricValue 转换为整数,然后再发送到elasticsearch

感谢您的任何想法。

C.C.

【问题讨论】:

    标签: regex elasticsearch type-conversion fluentd


    【解决方案1】:

    根据您的情况,您必须将这些字段 (types &lt;field_name_1&gt;:&lt;type_name_1&gt;,&lt;field_name_2&gt;:&lt;type_name_2&gt;,...) 放入 source 部分。 如果你使用parser插件,你必须将它插入filter部分(这里是example

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-09-12
      • 1970-01-01
      • 2020-12-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-27
      相关资源
      最近更新 更多