Hosted Graphite の API キーを取得しておく。ログインしたらトップページに表示されている。
fluentd にプラグインの設定を行う。
type forward
port 24224
bind 0.0.0.0
type copy
type stdout
type hosted_graphite
api_key cxxxxxxf-4xx4-4xx0-axx5-dxxxxxxxxxx9
metric_key foo.bar
protocol udp
とりあえずは type copy を使って fluentd のログにも出力させるようにしておく。尚、プラグインの設定は以下の通り。
オプション
パラメータ(例)
デフォルト値 / Required
説明
type
hosted_graphite
fluent-plugin-out_hosted_graphite を指定
api_key
cxxxxxxf-4xx4-4xx0-axx5-dxxxxxxxxxx9
なし / Required
Hosted Graphite の API キーを指定
metric_key
foo.bar
なし / Required
Record 内のキーを指定
protocol
udp
http / Required
メトリクスを転送する際のプロトコルを指定(HTTP or TCP or UDP)
以下のように fluentd を起動する。
fluentd -c conf/test.conf -o debug.log &
正常に起動したログを確認する。
(前略)
2015-01-11 00:51:09 +0000 [info]: reading config file path="conf/test.conf"
2015-01-11 00:51:09 +0000 [info]: starting fluentd-0.12.2
2015-01-11 00:51:09 +0000 [info]: gem 'fluent-plugin-out_hosted_graphite' version '0.0.1'
2015-01-11 00:51:09 +0000 [info]: gem 'fluentd' version '0.12.2'
2015-01-11 00:51:09 +0000 [info]: using configuration file:
type forward
port 24224
bind 0.0.0.0
type copy
type stdout
type hosted_graphite
api_key cxxxxxxf-4xx4-4xx0-axx5-dxxxxxxxxxx9
metric_key foo.bar
protocol udp
2015-01-11 00:51:09 +0000 [info]: adding match pattern="*.*" type="copy"
2015-01-11 00:51:09 +0000 [info]: adding source type="forward"
2015-01-11 00:51:09 +0000 [info]: listening fluent socket on 0.0.0.0:24224
更にテストで以下のようにメトリクスを送る。
while true
do
echo "{"foo.bar": $RANDOM, "memo": "test"}" | fluent-cat hosted-graphite.test
sleep 10
done