私は最近、fluentd + elasticsearch + kibana セットアップの使用を試み始めました。
私は現在、pythonコードで吐き出しているログファイルを読み取ることで、fluentdを介して情報をフィードしています。
ログは、次のように 1 行に 1 つずつ、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」に記入するためのfluentdセットアップがあります。
<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のままになります。
誰かが私が間違っていることを指摘できれば、とても感謝しています。