
fluent-plugin-mysqlrecord作ってみた
December 4, 2015,
tags:
fluentd
ruby
gem
生まれて初めてgemのパッケージを作ってみました。
fluent-plugin-mysqlrecord
fluent-plugin-mysqlで事足りるかと思ったのですが、どうやらkey_names
とかcolumns
を指定しなきゃいけないので、単純にinputしたデータを流すoutput pluginが欲しかったんですよね。
保存したいログの種類がたくさんあって、ログの種類毎にmysqlのテーブルに保存したかったのですが、設定ファイルに書いているとかなり大変だったので、作りました。
使い方
fluent-plugin-forestと組み合わせて、tagからテーブル名を指定して、そのテーブルにきたデータを流し込む見たいなイメージです。
もちろんfluent-plugin-forestを使わなくても大丈夫です。
<match application.**>
type forest
subtype mysqlrecord
<template>
host 127.0.0.1
database table_name
username root
password root
table ${tag_parts[1]}
flush_interval 5s
</template>
</match>
or
<match application.**>
type mysqlrecord
host 127.0.0.1
database table_name
username root
password root
table app_logs
flush_interval 5s
</match>
って感じで使えます。
最後に
テストは後で書きます・・・。