LoginSignup
19
19

More than 5 years have passed since last update.

fluentdでMongoDBにログを入れたときに、timeキーがない場合の対処

Last updated at Posted at 2014-09-09

fluentdのMongoDBプラグインを用いて、ログをMongoDBに入れる際に、
MongoDBの中のJSONをみると以下のように"time"のキーがなかった。

以下はApacheのaccess_logの例だが


{"_id" : ObjectId("540eef3f0d094e535e000028"),"host" : "10.2.4.249", "user" : "-", "method" : "GET", "path" : "/elb_healthcheck.php", "code" : "404", "size" : "293", "referer" : "-", "agent" : "ELB-HealthChecker/1.0" }

御覧のように"time"のキーが存在しない。

この場合はtd-agent.confにinclude_time_key trueを書く必要がある。


<match td.*.*>
  type mongo_replset
  database log
  collection access_log
  nodes localhost:27020,localhost:27021,localhost:27022
  flush_interval 10s
  include_time_key true  # ←こいつが必要★
</match>

これだけのことですが、めっちゃハマりました。どこにも書いてないんだもん。ソース見てやっとわかりましたよ。。。

19
19
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
19
19