in_sql: fix all_tables crash by passing a Config::Element to TableElement#configure (#178)
all_tablesbuilt each discovered table by passing a plain Hash toTableElement#configure, butFluent::Configurable#configureexpects aFluent::Config::Elementand calls#corresponding_proxieson it, so every discovered table raisedNoMethodErrorand#startfailed. Wrap the attributes in aFluent::Config::Element.
update_columndefaults tonil, so it no longer needs to be passed explicitly.Fixes #177
Signed-off-by: Shizuo Fujita fujita@clear-code.com Co-authored-by: Kentaro Hayashi kenhys@gmail.com
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802047560号
SQL input plugin for Fluentd event collector
Overview
This SQL plugin has two parts:
Requirements
NOTE: fluent-plugin-sql v2’s buffer format is different from v1. If you update the plugin to v2, don’t reuse v1’s buffer.
Installation
You should install actual RDBMS driver gem together.
pggem for postgresql adapter ormysql2gem formysql2adapter. Other adapters supported by ActiveRecord should work.We recommend that mysql2 gem is higher than
0.3.12and pg gem is higher than0.16.0.If you use ruby 2.1, use pg gem 0.21.0 (< 1.0.0) because ActiveRecord 5.1.4 or earlier doesn’t support Ruby 2.1.
Input: How It Works
This plugin runs following SQL periodically:
SELECT * FROM table WHERE update_column > last_update_column_value ORDER BY update_column ASC LIMIT 500
What you need to configure is update_column. The column should be an incremental column (such as AUTO_ INCREMENT primary key) so that this plugin reads newly INSERTed rows. Alternatively, you can use a column incremented every time when you update the row (such as
last_updated_atcolumn) so that this plugin reads the UPDATEd rows as well. If you omit to set update_column parameter, it uses primary key.It stores last selected rows to a file (named state_file) to not forget the last row when Fluentd restarts.
Input: Configuration
<table> sections:
Input: Limitation
You should make sure target tables have index (and/or partitions) on the update_column. Otherwise SELECT causes full table scan and serious performance problem.
You can’t replicate DELETEd rows.
Output: How It Works
This plugin takes advantage of ActiveRecord underneath. For
host,port,database,adapter,username,password,socketparameters, you can think of ActiveRecord’s equivalent parameters.Output: Configuration
<table> sections:
from:toorkeyvalues are separated by,. For example, if set ‘item_id:id,item_text:data,updated_at’ to column_mapping,item_idfield of record is stored intoidcolumn andupdated_atfield of record is stored intoupdated_atcolumn.remove_tag_prefix, if given). The patterns should follow the same syntax as that of <match>. Exactly one <table> element must NOT have this parameter so that it becomes the default table to store data.