【发布时间】: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