logstash-output-clickhouse 0.1.4 → 0.1.5
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 +4 -4
- data/README.md +2 -0
- data/lib/logstash/outputs/clickhouse.rb +17 -6
- data/logstash-output-clickhouse.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34905df0e9293b2ff6471b904e018e8fe3d2d2f1bc372196422d5fa30107d50e
|
4
|
+
data.tar.gz: a20ec2301377b218b8395f6664be86f4b978e6ad72c42280fa2bfc0c889c0569
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccbd71994f6b705088616315a3340312381fce0ccae1dc4f97b793d417041d987ede5962c6f256111d6a78620bed275997153c9fa37bc86ca4770c4642469726
|
7
|
+
data.tar.gz: e0b00ed0a0b0f1e8a664698cd0c1258d48d67bf872afe983b26d9134ddead047852bfecebaa7d9fa7668400c94de76d0e1bd1475b074f11308d0b87a7f3a6284
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Logstash Plugin
|
2
2
|
[](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
|
-
|
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 =
|
125
|
+
documents = {}
|
119
126
|
|
120
127
|
events.each do |event|
|
121
|
-
|
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
|
-
|
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.
|
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
|
+
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-
|
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
|