Class: Fluent::ClickHouseJsonOutput
- Inherits:
-
BufferedOutput
- Object
- BufferedOutput
- Fluent::ClickHouseJsonOutput
- Includes:
- SetTagKeyMixin, SetTimeKeyMixin
- Defined in:
- lib/fluent/plugin/out_clickhousejson.rb
Instance Attribute Summary collapse
-
#handler ⇒ Object
Returns the value of attribute handler.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #format(tag, time, record) ⇒ Object
-
#initialize ⇒ ClickHouseJsonOutput
constructor
A new instance of ClickHouseJsonOutput.
- #shutdown ⇒ Object
- #start ⇒ Object
- #write(chunk) ⇒ Object
Constructor Details
#initialize ⇒ ClickHouseJsonOutput
Returns a new instance of ClickHouseJsonOutput.
21 22 23 24 25 |
# File 'lib/fluent/plugin/out_clickhousejson.rb', line 21 def initialize super require 'click_house' end |
Instance Attribute Details
#handler ⇒ Object
Returns the value of attribute handler.
18 19 20 |
# File 'lib/fluent/plugin/out_clickhousejson.rb', line 18 def handler @handler end |
#path ⇒ Object
Returns the value of attribute path.
19 20 21 |
# File 'lib/fluent/plugin/out_clickhousejson.rb', line 19 def path @path end |
Instance Method Details
#configure(conf) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/fluent/plugin/out_clickhousejson.rb', line 31 def configure(conf) super @cf = {} if conf['username'] @cf['username'] = conf['username'] end if conf['password'] @cf['password'] = conf['password'] end if conf['url'] @url = @url.split(',').map { |m| m.strip } elsif conf['host'] @cf['host'] = conf['host'] end if conf['port'] @cf['port'] = conf['port'] end @cf['database'] = conf['database'] end |
#format(tag, time, record) ⇒ Object
61 62 63 |
# File 'lib/fluent/plugin/out_clickhousejson.rb', line 61 def format(tag, time, record) [tag, time, record].to_msgpack end |
#shutdown ⇒ Object
57 58 59 |
# File 'lib/fluent/plugin/out_clickhousejson.rb', line 57 def shutdown super end |
#start ⇒ Object
53 54 55 |
# File 'lib/fluent/plugin/out_clickhousejson.rb', line 53 def start super end |
#write(chunk) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/fluent/plugin/out_clickhousejson.rb', line 65 def write(chunk) ClickHouse.config do |config| config.host = @cf['host'] config.port = @cf['port'] config.username = @cf['username'] config.password = @cf['password'] end ClickHouse.connection.insert(@table) do |rows| chunk.msgpack_each { |tag, time, record| rows << JSON.parse(JSON[record]) } rows end end |