fluentdのin_tailで特定フィールドをintに変えたい

fluentdのin_tailでApacheアクセスログをmongodbに突っ込んでたんだけど、
数値比較の絞り込みがうまくできない。

> db.access.find({size:{"$gt":100}})


そうですよね、全部文字列でした!

> db.access.find();
{ "_id" : ObjectId("4fb124dd32ddfb55bc000003"), "host" : "127.0.0.1", "user" : "-", "method" : "GET", "path" : "/test2.txt", "code" : "404", "size" : "281", "referer" : "-", "agent" : "curl/7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5", "time" : ISODate("2012-05-14T15:29:33Z") }


というわけで指定したキーだけ数値に変換するようにテキトウなin_tailの拡張を書いて、
(良い子はちゃんとエラー処理しようね!)

module Fluent
class MyTailInput < TailInput
  Fluent::Plugin.register_input('mytail', self)

  config_param :to_i, :string

  def configure(conf)
    super

    @to_i = @to_i.split(',').map {|key| key.strip }
  end

  def parse_line(line)
    time, record = @parser.parse(line)
    @to_i.each {|key|
      record[key] = record[key].to_i
    }
    return time, record
  end
end
end

設定を変更

<source>
  type mytail
#  type tail
  format apache
  path /var/log/httpd/access_log
  tag apache.access
  to_i size,code
</source>

数値で入るようになりました

> db.access.find({size:{"$gt":100}})
{ "_id" : ObjectId("4fb125b032ddfb5823000003"), "host" : "127.0.0.1", "user" : "-", "method" : "GET", "path" : "/test2.txt", "code" : 404, "size" : 281, "referer" : "-", "agent" : "curl/7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5", "time" : ISODate("2012-05-14T15:33:03Z") }

ムリヤリ過ぎる!本家で対応してくれそうな感じもあったのでとりあえずこれで様子見