logstash-output-clickhouse 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 20cb59bb456f397ff9408209d676deb3c46214abbd874a5499ab5f7387bb80b9
4
- data.tar.gz: 471cd0087a01acbcd6ed8efaa93e09f89102a2b2785bcfa7bb117e7ed8dd2b0d
3
+ metadata.gz: 34905df0e9293b2ff6471b904e018e8fe3d2d2f1bc372196422d5fa30107d50e
4
+ data.tar.gz: a20ec2301377b218b8395f6664be86f4b978e6ad72c42280fa2bfc0c889c0569
5
5
  SHA512:
6
- metadata.gz: 3319460b03965943afecff0c3b910ebfb57611566f02b255b7fb3afd6b2a7f6781b89990cf667286972ed27bb503b90833a300f20450a0ad3e637c2144b3f37e
7
- data.tar.gz: 609792b63cc1aa8d073f272e9539458738914c4ed1a795b22e23d6a86724b6e9c7e0277b533d0e02fa03d40168799197a614d3208e129b8ba534a8bb3ea80aee
6
+ metadata.gz: ccbd71994f6b705088616315a3340312381fce0ccae1dc4f97b793d417041d987ede5962c6f256111d6a78620bed275997153c9fa37bc86ca4770c4642469726
7
+ data.tar.gz: e0b00ed0a0b0f1e8a664698cd0c1258d48d67bf872afe983b26d9134ddead047852bfecebaa7d9fa7668400c94de76d0e1bd1475b074f11308d0b87a7f3a6284
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Logstash Plugin
2
2
  [![Gem Version](https://badge.fury.io/rb/logstash-output-clickhouse.svg)](https://badge.fury.io/rb/logstash-output-clickhouse)
3
3
 
4
+ This repo forked from [here](https://github.com/funcmike/logstash-output-clickhouse).
5
+
4
6
  This plugin is a modified version of the Lucidworks logstash json_batch. That plugin is available [here](https://github.com/lucidworks/logstash-output-json_batch).
5
7
 
6
8
  It has been modified to support ClickHouse JSON Format, but also supports fault tolerance.
@@ -58,7 +58,6 @@ class LogStash::Outputs::ClickHouse < LogStash::Outputs::Base
58
58
  :idle_flush_time => @idle_flush_time,
59
59
  :request_tokens => @pool_max,
60
60
  :http_hosts => @http_hosts,
61
- :http_query => @http_query,
62
61
  :headers => request_headers)
63
62
  end
64
63
 
@@ -74,8 +73,7 @@ class LogStash::Outputs::ClickHouse < LogStash::Outputs::Base
74
73
  @pool_max.times { |t| @request_tokens << true }
75
74
  @requests = Array.new
76
75
 
77
- params = { "query" => "INSERT INTO #{table} FORMAT JSONEachRow" }.merge(@extra_params)
78
- @http_query = "?#{URI.encode_www_form(params)}"
76
+ @table_name = table
79
77
 
80
78
  buffer_initialize(
81
79
  :max_items => @flush_size,
@@ -91,6 +89,15 @@ class LogStash::Outputs::ClickHouse < LogStash::Outputs::Base
91
89
  buffer_receive(event)
92
90
  end
93
91
 
92
+ def generate_table_name(event)
93
+ event.sprintf(@table_name)
94
+ end
95
+
96
+ def generate_http_query(table_name)
97
+ params = { "query" => "INSERT INTO #{table_name} FORMAT JSONEachRow" }.merge(@extra_params)
98
+ return "?#{URI.encode_www_form(params)}"
99
+ end
100
+
94
101
  def mutate(src)
95
102
  return src if @mutations.empty?
96
103
  res = {}
@@ -115,15 +122,19 @@ class LogStash::Outputs::ClickHouse < LogStash::Outputs::Base
115
122
  public
116
123
 
117
124
  def flush(events, close = false)
118
- documents = "" #this is the string of hashes that we push to Fusion as documents
125
+ documents = {}
119
126
 
120
127
  events.each do |event|
121
- documents << LogStash::Json.dump(mutate(event.to_hash())) << "\n"
128
+ table_name = generate_table_name(event)
129
+ documents[table_name] ||= ""
130
+ documents[table_name] << LogStash::Json.dump(mutate(event.to_hash())) << "\n"
122
131
  end
123
132
 
124
133
  hosts = @http_hosts.clone
125
134
 
126
- make_request(documents, hosts, @http_query, 1, 1, hosts.sample)
135
+ documents.each do |table_name, document|
136
+ make_request(document, hosts, generate_http_query(table_name), 1, 1, hosts.sample)
137
+ end
127
138
  end
128
139
 
129
140
  private
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "logstash-output-clickhouse"
3
- s.version = "0.1.4"
3
+ s.version = "0.1.5"
4
4
  s.licenses = ["Apache-2.0"]
5
5
  s.summary = "This output lets you `POST` messages as JSON in a batched fashion to ClickHouse HTTP endpoint"
6
6
  s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-clickhouse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - kmajk
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-04-27 00:00:00.000000000 Z
12
+ date: 2023-05-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: logstash-core-plugin-api