fluent-plugin-clickhouse-output 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f3b8c77b050b4181339da242a1e39b6bd3019ff0046404395723e57a207e389d
4
+ data.tar.gz: 674c5dcdc0a8b839482afcd6c646cd5821e0ecd9558ce65aca2f0487eee2824c
5
+ SHA512:
6
+ metadata.gz: bff6c90bd1af01fd3218e8afe72764c6ded856a1cf99c87e0318ad076759f284a2c4f43a899c85736ea824c8c6f5f474744a99dc530e03d5e182feeaedc6cae7
7
+ data.tar.gz: 0b540b0d0e2c3d228f8d0a548c436096c92850cc6ebbd11af6daa698db131d107cdcff7299b323db8bc06336a8c5e1e667b9d1388f1b5fef8d1b03feeaaf7514
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ /.idea
2
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,102 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ fluent-plugin-clickhouse-output (0.0.2)
5
+ clickhouse (~> 0.1)
6
+ fluentd (~> 1.12)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activesupport (6.1.3.2)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (>= 1.6, < 2)
14
+ minitest (>= 5.1)
15
+ tzinfo (~> 2.0)
16
+ zeitwerk (~> 2.3)
17
+ addressable (2.7.0)
18
+ public_suffix (>= 2.0.2, < 5.0)
19
+ clickhouse (0.1.10)
20
+ activesupport (>= 4.1.8)
21
+ bundler (>= 1.13.4)
22
+ erubis
23
+ faraday
24
+ launchy
25
+ pond
26
+ sinatra
27
+ thor
28
+ concurrent-ruby (1.1.8)
29
+ cool.io (1.7.1)
30
+ erubis (2.7.0)
31
+ faraday (1.4.2)
32
+ faraday-em_http (~> 1.0)
33
+ faraday-em_synchrony (~> 1.0)
34
+ faraday-excon (~> 1.1)
35
+ faraday-net_http (~> 1.0)
36
+ faraday-net_http_persistent (~> 1.1)
37
+ multipart-post (>= 1.2, < 3)
38
+ ruby2_keywords (>= 0.0.4)
39
+ faraday-em_http (1.0.0)
40
+ faraday-em_synchrony (1.0.0)
41
+ faraday-excon (1.1.0)
42
+ faraday-net_http (1.0.1)
43
+ faraday-net_http_persistent (1.1.0)
44
+ fluentd (1.13.0)
45
+ bundler
46
+ cool.io (>= 1.4.5, < 2.0.0)
47
+ http_parser.rb (>= 0.5.1, < 0.7.0)
48
+ msgpack (>= 1.3.1, < 2.0.0)
49
+ serverengine (>= 2.2.2, < 3.0.0)
50
+ sigdump (~> 0.2.2)
51
+ strptime (>= 0.2.2, < 1.0.0)
52
+ tzinfo (>= 1.0, < 3.0)
53
+ tzinfo-data (~> 1.0)
54
+ webrick (>= 1.4.2, < 1.8.0)
55
+ yajl-ruby (~> 1.0)
56
+ http_parser.rb (0.6.0)
57
+ i18n (1.8.10)
58
+ concurrent-ruby (~> 1.0)
59
+ launchy (2.5.0)
60
+ addressable (~> 2.7)
61
+ minitest (5.14.4)
62
+ msgpack (1.4.2)
63
+ multipart-post (2.1.1)
64
+ mustermann (1.1.1)
65
+ ruby2_keywords (~> 0.0.1)
66
+ pond (0.5.0)
67
+ public_suffix (4.0.6)
68
+ rack (2.2.3)
69
+ rack-protection (2.1.0)
70
+ rack
71
+ rake (10.5.0)
72
+ ruby2_keywords (0.0.4)
73
+ serverengine (2.2.4)
74
+ sigdump (~> 0.2.2)
75
+ sigdump (0.2.4)
76
+ sinatra (2.1.0)
77
+ mustermann (~> 1.0)
78
+ rack (~> 2.2)
79
+ rack-protection (= 2.1.0)
80
+ tilt (~> 2.0)
81
+ strptime (0.2.5)
82
+ thor (1.1.0)
83
+ tilt (2.0.10)
84
+ tzinfo (2.0.4)
85
+ concurrent-ruby (~> 1.0)
86
+ tzinfo-data (1.2021.1)
87
+ tzinfo (>= 1.0.0)
88
+ webrick (1.7.0)
89
+ yajl-ruby (1.4.1)
90
+ zeitwerk (2.4.2)
91
+
92
+ PLATFORMS
93
+ ruby
94
+ x86_64-linux
95
+
96
+ DEPENDENCIES
97
+ bundler (~> 1.17)
98
+ fluent-plugin-clickhouse-output!
99
+ rake (~> 10.0)
100
+
101
+ BUNDLED WITH
102
+ 1.17.3
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Fluent::Plugin::Clickhouse
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'fluent-plugin-clickhouse-output'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install fluent-plugin-clickhouse-output
18
+
19
+ ## Development
20
+
21
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
22
+
23
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
24
+
25
+ ## Contributing
26
+
27
+ Bug reports and pull requests are welcome on GitHub at https://github.com/amlivedn/fluent-plugin-clickhouse-output. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
28
+
29
+ ## License
30
+
31
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
32
+
33
+ ## Code of Conduct
34
+
35
+ Everyone interacting in the Fluent::Plugin::Clickhouse project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/fluent-plugin-clickhouse/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,32 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'fluent-plugin-clickhouse-output'
8
+ spec.version = '0.0.2'
9
+ spec.authors = ['Alex Malyi']
10
+ spec.email = ['am@pixelx.pro']
11
+
12
+ spec.summary = %q{Fluentd output plugin for inserting into ClickHouse.}
13
+ spec.description = %q{Fluentd output inserted into ClickHouse as fast column-oriented OLAP DBMS.}
14
+ spec.homepage = 'https://github.com/amlivedn/fluentd-plugin-clickhouse-output'
15
+ spec.license = 'MIT'
16
+
17
+ spec.rubyforge_project = 'fluent-plugin-clickhouse-output'
18
+
19
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
20
+ f.match(%r{^(test|spec|features)/})
21
+ end
22
+
23
+ spec.bindir = 'exe'
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ['lib']
26
+
27
+ spec.add_development_dependency 'bundler', '~> 1.17'
28
+ spec.add_development_dependency 'rake', '~> 10.0'
29
+
30
+ spec.add_runtime_dependency 'fluentd', '~> 1.12'
31
+ spec.add_runtime_dependency 'clickhouse', '~> 0.1'
32
+ end
@@ -0,0 +1,80 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ module Fluent
4
+ class ClickHouseOutput < Fluent::BufferedOutput
5
+ Fluent::Plugin.register_output('clickhouse-output', self)
6
+
7
+ include Fluent::SetTimeKeyMixin
8
+ include Fluent::SetTagKeyMixin
9
+
10
+ config_param :host, :string, :default => 'localhost'
11
+ config_param :port, :string, :default => 8192
12
+ config_param :urls, :string, :default => nil
13
+ config_param :database, :string, :default => 'default'
14
+ config_param :username, :string, :default => 'default'
15
+ config_param :password, :string, :default => nil, :secret => true
16
+
17
+ config_param :table, :string, :default => nil
18
+ config_param :columns, :string, :default => nil
19
+
20
+ attr_accessor :handler
21
+ attr_accessor :path
22
+
23
+ def initialize
24
+ super
25
+
26
+ require 'clickhouse'
27
+ end
28
+
29
+ unless method_defined?(:log)
30
+ define_method('log') { $log }
31
+ end
32
+
33
+ def configure(conf)
34
+ super
35
+ if conf['columns']
36
+ @columns = conf['columns'].split(',').map { |m| m.strip }
37
+ end
38
+ @config = {}
39
+ if conf['username']
40
+ @config['username'] = conf['username']
41
+ end
42
+ if conf['password']
43
+ @config['password'] = conf['password']
44
+ end
45
+
46
+ if conf['urls']
47
+ @urls = @urls.split(',').map { |m| m.strip }
48
+ elsif conf['host']
49
+ @config['host'] = conf['host']
50
+ end
51
+ if conf['port']
52
+ @config['port'] = conf['port']
53
+ end
54
+
55
+ @config['database'] = conf['database']
56
+ end
57
+
58
+ def start
59
+ super
60
+ end
61
+
62
+ def shutdown
63
+ super
64
+ end
65
+
66
+ def format(tag, time, record)
67
+ [tag, time, record].to_msgpack
68
+ end
69
+
70
+ def write(chunk)
71
+ Clickhouse.establish_connection(@config)
72
+ Clickhouse.connection.insert_rows(@table, :names => @columns) { |rows|
73
+ chunk.msgpack_each { |tag, time, record|
74
+ rows << @columns.map { |m| record[m] }
75
+ }
76
+ rows
77
+ }
78
+ end
79
+ end
80
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-clickhouse-output
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Alex Malyi
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-06-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.17'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.17'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: fluentd
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.12'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.12'
55
+ - !ruby/object:Gem::Dependency
56
+ name: clickhouse
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.1'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.1'
69
+ description: Fluentd output inserted into ClickHouse as fast column-oriented OLAP
70
+ DBMS.
71
+ email:
72
+ - am@pixelx.pro
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - Gemfile
79
+ - Gemfile.lock
80
+ - README.md
81
+ - fluent-plugin-clickhouse-output.gemspec
82
+ - lib/fluent/plugin/out_clickhouse.rb
83
+ homepage: https://github.com/amlivedn/fluentd-plugin-clickhouse-output
84
+ licenses:
85
+ - MIT
86
+ metadata: {}
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubygems_version: 3.1.2
103
+ signing_key:
104
+ specification_version: 4
105
+ summary: Fluentd output plugin for inserting into ClickHouse.
106
+ test_files: []