我最近开始尝试使用 fluentd + elasticsearch + kibana 设置。
我目前正在通过 fluentd 提供信息,方法是让它读取我用 python 代码吐出的日志文件。
日志由 json 数据列表组成,每行一个,如下所示:
{"id": "1","date": "2014-02-01T09:09:59.000+09:00","protocol": "tcp","source ip": "xxxx.xxxx.xxxx.xxxx","source port": "37605","country": "CN","organization": "China Telecom jiangsu","dest ip": "xxxx.xxxx.xxxx.xxxx","dest port": "23"}
我有流利的设置来读取我的字段“id”并按照此处的说明填写“_id” :
<source>
type tail
path /home/(usr)/bin1/fluentd.log
tag es
format json
keys id, date, prot, srcip, srcport, country, org, dstip, dstport
id_key id
time_key date
time_format %Y-%m-%dT%H:%M:%S.%L%:z
</source>
<match es.**>
type elasticsearch
logstash_format true
flush_interval 10s # for testing
</match>
但是,插入上面的“_id”仍然是随机生成的_id。
如果有人能指出我做错了什么,我将不胜感激。