Fluentdのin_tail機能を使っていると数値として扱ってほしいのに
フィールドの値が文字列になってしまって、
fluent-plugin-typecastを使うことがあると思います。
しかし、version 0.10.42以上のFluentdであれば、
in_tailにtypesオプションという型が指定できるオプションが加わったため、
fluent-plugin-typecastを使う必要がなくなりました。
syntaxは
types <field_name_1>:<type_name_1>,<field_name_2>:<type_name_2>,...
です。
以下が設定例。
<source> type tail path /var/log/access.log pos_file /var/log/td-agent/access.log.pos tag access format ltsv types user_id:integer,response_time:float </source>
typesオプションに指定しなかったフィールドは文字列になります。
型は以下が指定出来るみたいです。
- string
- bool
- integer
- float
- time
- array
詳しくは http://docs.fluentd.org/articles/in_tail のtypesオプションの項目を見て下さい。
※理想は、
http://y-ken.hatenablog.com/entry/fluentd-parser-auto-type-conversion
にあるように自動で型判別するオプションも欲しかったところですが…。