logstash-input-jdbc 4.1.1 → 4.1.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 +4 -4
- data/CHANGELOG.md +29 -18
- data/lib/logstash/inputs/jdbc.rb +4 -0
- data/lib/logstash/plugin_mixins/jdbc.rb +12 -3
- data/logstash-input-jdbc.gemspec +1 -2
- data/spec/inputs/jdbc_spec.rb +47 -6
- metadata +3 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a78d72e92aa01bf8891190bf7f03fb389f26b59f
|
|
4
|
+
data.tar.gz: 014325a08ad778dcc57aafeca4c45978be18abf7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8d4841251922f7b763a4972e5cd47b8b499f419b4c4771656dea5a769c0bc9484eda5591073b37b34ba46c262b27dfef5b217e8a559aa731c80886bc29f9f9a8
|
|
7
|
+
data.tar.gz: c9913e1d5b4b686d085d9875b38a7a27837ba8a327fa3cd4ce326bf5ffab5e24d630cd3a3184e5aea4a6f8a871f338d0a8d249db78295c8e8933d0c645e4cc72
|
data/CHANGELOG.md
CHANGED
|
@@ -1,36 +1,47 @@
|
|
|
1
|
+
## 4.1.2
|
|
2
|
+
- [internal] Removed docker dependencies for testing
|
|
3
|
+
|
|
1
4
|
## 4.1.1
|
|
2
|
-
|
|
5
|
+
- Relax constraint on logstash-core-plugin-api to >= 1.60 <= 2.99
|
|
3
6
|
|
|
4
7
|
## 4.1.0
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
- Add an option to select the encoding data should be transform from,
|
|
9
|
+
this will make sure all strings read from the jdbc connector are
|
|
10
|
+
noremalized to be UTF-8 so no causing issues with later filters in LS.
|
|
11
|
+
|
|
8
12
|
## 4.0.1
|
|
9
|
-
|
|
13
|
+
- Republish all the gems under jruby.
|
|
14
|
+
|
|
10
15
|
## 4.0.0
|
|
11
|
-
|
|
16
|
+
- Update the plugin to the version 2.0 of the plugin api, this change is required for Logstash 5.0 compatibility. See https://github.com/elastic/logstash/issues/5141
|
|
17
|
+
|
|
12
18
|
# 3.0.3
|
|
13
|
-
|
|
19
|
+
- Added feature to read password from external file (#120)
|
|
20
|
+
|
|
14
21
|
# 3.0.2
|
|
15
|
-
|
|
22
|
+
- Depend on logstash-core-plugin-api instead of logstash-core, removing the need to mass update plugins on major releases of logstash
|
|
23
|
+
|
|
16
24
|
# 3.0.1
|
|
17
|
-
|
|
25
|
+
- New dependency requirements for logstash-core for the 5.0 release
|
|
26
|
+
- feature: Added configurable support for retrying database connection
|
|
27
|
+
failures.
|
|
28
|
+
|
|
18
29
|
## 3.0.0
|
|
19
|
-
|
|
30
|
+
- [#57](https://github.com/logstash-plugins/logstash-input-jdbc/issues/57) New feature: Allow tracking by a column value rather than by last run time. **This is a breaking change**, as users may be required to change from using `sql_last_start` to use `sql_last_value` in their queries. No other changes are required if you've been using time-based queries. See the documentation if you wish to use an incremental column value to track updates to your tables.
|
|
20
31
|
|
|
21
32
|
## 2.1.1
|
|
22
|
-
|
|
33
|
+
- [#44](https://github.com/logstash-plugins/logstash-input-jdbc/issues/44) add option to control the lowercase or not, of the column names.
|
|
23
34
|
|
|
24
35
|
## 2.1.0
|
|
25
|
-
|
|
26
|
-
|
|
36
|
+
- [#85](https://github.com/logstash-plugins/logstash-input-jdbc/issues/85) make the jdbc_driver_library accept a list of elements separated by commas as in some situations we might need to load more than one jar/lib.
|
|
37
|
+
- [#89](https://github.com/logstash-plugins/logstash-input-jdbc/issues/89) Set application timezone for cases where time fields in data have no timezone.
|
|
27
38
|
|
|
28
39
|
## 2.0.5
|
|
29
|
-
|
|
40
|
+
- [#77](https://github.com/logstash-plugins/logstash-input-jdbc/issues/77) Time represented as RubyTime and not as Logstash::Timestamp
|
|
30
41
|
|
|
31
42
|
## 2.0.4
|
|
32
|
-
|
|
33
|
-
|
|
43
|
+
- [#70](https://github.com/logstash-plugins/logstash-input-jdbc/pull/70) prevents multiple queries from being run at the same time
|
|
44
|
+
- [#69](https://github.com/logstash-plugins/logstash-input-jdbc/pull/69) pass password as string to Sequel
|
|
34
45
|
|
|
35
46
|
## 2.0.3
|
|
36
47
|
- Added ability to configure timeout
|
|
@@ -41,5 +52,5 @@
|
|
|
41
52
|
instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
|
|
42
53
|
- Dependency on logstash-core update to 2.0
|
|
43
54
|
|
|
44
|
-
|
|
45
|
-
|
|
55
|
+
## 1.0.0
|
|
56
|
+
- Initial release
|
data/lib/logstash/inputs/jdbc.rb
CHANGED
|
@@ -151,6 +151,9 @@ class LogStash::Inputs::Jdbc < LogStash::Inputs::Base
|
|
|
151
151
|
# If tracking column value rather than timestamp, the column whose value is to be tracked
|
|
152
152
|
config :tracking_column, :validate => :string
|
|
153
153
|
|
|
154
|
+
# Type of tracking column. Currently only "numeric" and "timestamp"
|
|
155
|
+
config :tracking_column_type, :validate => ['numeric', 'timestamp'], :default => 'numeric'
|
|
156
|
+
|
|
154
157
|
# Whether the previous run state should be preserved
|
|
155
158
|
config :clean_run, :validate => :boolean, :default => false
|
|
156
159
|
|
|
@@ -183,6 +186,7 @@ class LogStash::Inputs::Jdbc < LogStash::Inputs::Base
|
|
|
183
186
|
public
|
|
184
187
|
|
|
185
188
|
def register
|
|
189
|
+
@logger = self.logger
|
|
186
190
|
require "rufus/scheduler"
|
|
187
191
|
prepare_jdbc_connection
|
|
188
192
|
|
|
@@ -8,8 +8,6 @@ require "date"
|
|
|
8
8
|
# for potential reuse in other plugins (input/output)
|
|
9
9
|
module LogStash::PluginMixins::Jdbc
|
|
10
10
|
|
|
11
|
-
@logger = Cabin::Channel.get(LogStash)
|
|
12
|
-
|
|
13
11
|
# This method is called when someone includes this module
|
|
14
12
|
def self.included(base)
|
|
15
13
|
# Add these methods to the 'base' given.
|
|
@@ -183,7 +181,12 @@ module LogStash::PluginMixins::Jdbc
|
|
|
183
181
|
@database.identifier_output_method = :to_s
|
|
184
182
|
end
|
|
185
183
|
if @use_column_value
|
|
186
|
-
@
|
|
184
|
+
case @tracking_column_type
|
|
185
|
+
when "numeric"
|
|
186
|
+
@sql_last_value = 0
|
|
187
|
+
when "timestamp"
|
|
188
|
+
@sql_last_value = Time.at(0).utc
|
|
189
|
+
end
|
|
187
190
|
else
|
|
188
191
|
@sql_last_value = Time.at(0).utc
|
|
189
192
|
end
|
|
@@ -208,12 +211,18 @@ module LogStash::PluginMixins::Jdbc
|
|
|
208
211
|
query.each_page(@jdbc_page_size) do |paged_dataset|
|
|
209
212
|
paged_dataset.each do |row|
|
|
210
213
|
sql_last_value = get_column_value(row) if @use_column_value
|
|
214
|
+
if @tracking_column_type=="timestamp" and @use_column_value and sql_last_value.is_a?(DateTime)
|
|
215
|
+
sql_last_value=Time.parse(sql_last_value.to_s) # Coerce the timestamp to a `Time`
|
|
216
|
+
end
|
|
211
217
|
yield extract_values_from(row)
|
|
212
218
|
end
|
|
213
219
|
end
|
|
214
220
|
else
|
|
215
221
|
query.each do |row|
|
|
216
222
|
sql_last_value = get_column_value(row) if @use_column_value
|
|
223
|
+
if @tracking_column_type=="timestamp" and @use_column_value and sql_last_value.is_a?(DateTime)
|
|
224
|
+
sql_last_value=Time.parse(sql_last_value.to_s) # Coerce the timestamp to a `Time`
|
|
225
|
+
end
|
|
217
226
|
yield extract_values_from(row)
|
|
218
227
|
end
|
|
219
228
|
end
|
data/logstash-input-jdbc.gemspec
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Gem::Specification.new do |s|
|
|
2
2
|
s.name = 'logstash-input-jdbc'
|
|
3
|
-
s.version = '4.1.
|
|
3
|
+
s.version = '4.1.2'
|
|
4
4
|
s.licenses = ['Apache License (2.0)']
|
|
5
5
|
s.summary = "This example input streams a string at a definable interval."
|
|
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/logstash-plugin install gemname. This gem is not a stand-alone program"
|
|
@@ -28,5 +28,4 @@ Gem::Specification.new do |s|
|
|
|
28
28
|
s.add_development_dependency 'logstash-devutils'
|
|
29
29
|
s.add_development_dependency 'timecop'
|
|
30
30
|
s.add_development_dependency 'jdbc-derby'
|
|
31
|
-
s.add_development_dependency 'docker-api'
|
|
32
31
|
end
|
data/spec/inputs/jdbc_spec.rb
CHANGED
|
@@ -463,6 +463,50 @@ describe LogStash::Inputs::Jdbc do
|
|
|
463
463
|
end
|
|
464
464
|
end
|
|
465
465
|
|
|
466
|
+
context "when iteratively running plugin#run with timestamp tracking column with column value" do
|
|
467
|
+
let(:mixin_settings) do
|
|
468
|
+
{ "jdbc_user" => ENV['USER'], "jdbc_driver_class" => "org.apache.derby.jdbc.EmbeddedDriver",
|
|
469
|
+
"jdbc_connection_string" => "jdbc:derby:memory:testdb;create=true"
|
|
470
|
+
}
|
|
471
|
+
end
|
|
472
|
+
|
|
473
|
+
let(:settings) do
|
|
474
|
+
{ "statement" => "SELECT num, created_at, custom_time FROM test_table WHERE custom_time > :sql_last_value",
|
|
475
|
+
"use_column_value" => true,
|
|
476
|
+
"tracking_column" => "custom_time",
|
|
477
|
+
"tracking_column_type" => "timestamp",
|
|
478
|
+
"last_run_metadata_path" => Stud::Temporary.pathname }
|
|
479
|
+
end
|
|
480
|
+
|
|
481
|
+
let(:nums) { [10, 20, 30, 40, 50] }
|
|
482
|
+
let(:times) {["2015-05-06 13:14:15","2015-05-07 13:14:15","2015-05-08 13:14:15","2015-05-09 13:14:15","2015-05-10 13:14:15"]}
|
|
483
|
+
|
|
484
|
+
before do
|
|
485
|
+
plugin.register
|
|
486
|
+
end
|
|
487
|
+
|
|
488
|
+
after do
|
|
489
|
+
plugin.stop
|
|
490
|
+
end
|
|
491
|
+
|
|
492
|
+
it "should successfully update sql_last_value" do
|
|
493
|
+
test_table = db[:test_table]
|
|
494
|
+
|
|
495
|
+
plugin.run(queue)
|
|
496
|
+
expect(plugin.instance_variable_get("@sql_last_value")).to eq(Time.parse("1970-01-01 00:00:00.000000000 +0000"))
|
|
497
|
+
test_table.insert(:num => nums[0], :created_at => Time.now.utc, :custom_time => times[0])
|
|
498
|
+
test_table.insert(:num => nums[1], :created_at => Time.now.utc, :custom_time => times[1])
|
|
499
|
+
plugin.run(queue)
|
|
500
|
+
expect(plugin.instance_variable_get("@sql_last_value").class).to eq(Time.parse(times[0]).class)
|
|
501
|
+
expect(plugin.instance_variable_get("@sql_last_value")).to eq(Time.parse(times[1]))
|
|
502
|
+
test_table.insert(:num => nums[2], :created_at => Time.now.utc, :custom_time => times[2])
|
|
503
|
+
test_table.insert(:num => nums[3], :created_at => Time.now.utc, :custom_time => times[3])
|
|
504
|
+
test_table.insert(:num => nums[4], :created_at => Time.now.utc, :custom_time => times[4])
|
|
505
|
+
plugin.run(queue)
|
|
506
|
+
expect(plugin.instance_variable_get("@sql_last_value")).to eq(Time.parse(times[4]))
|
|
507
|
+
end
|
|
508
|
+
end
|
|
509
|
+
|
|
466
510
|
context "when iteratively running plugin#run with tracking_column and stored metadata" do
|
|
467
511
|
let(:mixin_settings) do
|
|
468
512
|
{ "jdbc_user" => ENV['USER'], "jdbc_driver_class" => "org.apache.derby.jdbc.EmbeddedDriver",
|
|
@@ -821,8 +865,7 @@ describe LogStash::Inputs::Jdbc do
|
|
|
821
865
|
let(:num_rows) { 5 }
|
|
822
866
|
|
|
823
867
|
before do
|
|
824
|
-
plugin.
|
|
825
|
-
allow(logger).to receive(:debug?)
|
|
868
|
+
allow(plugin.logger).to receive(:debug?)
|
|
826
869
|
num_rows.times do
|
|
827
870
|
db[:test_table].insert(:num => 1)
|
|
828
871
|
end
|
|
@@ -834,10 +877,8 @@ describe LogStash::Inputs::Jdbc do
|
|
|
834
877
|
plugin.stop
|
|
835
878
|
end
|
|
836
879
|
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
it "should report the staments to logging" do
|
|
840
|
-
expect(logger).to receive(:debug).with(kind_of(String)).once
|
|
880
|
+
it "should report the statements to logging" do
|
|
881
|
+
expect(plugin.logger).to receive(:debug).once
|
|
841
882
|
plugin.run(queue)
|
|
842
883
|
end
|
|
843
884
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: logstash-input-jdbc
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.1.
|
|
4
|
+
version: 4.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Elastic
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-
|
|
11
|
+
date: 2016-10-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -142,20 +142,6 @@ dependencies:
|
|
|
142
142
|
- - ">="
|
|
143
143
|
- !ruby/object:Gem::Version
|
|
144
144
|
version: '0'
|
|
145
|
-
- !ruby/object:Gem::Dependency
|
|
146
|
-
requirement: !ruby/object:Gem::Requirement
|
|
147
|
-
requirements:
|
|
148
|
-
- - ">="
|
|
149
|
-
- !ruby/object:Gem::Version
|
|
150
|
-
version: '0'
|
|
151
|
-
name: docker-api
|
|
152
|
-
prerelease: false
|
|
153
|
-
type: :development
|
|
154
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
155
|
-
requirements:
|
|
156
|
-
- - ">="
|
|
157
|
-
- !ruby/object:Gem::Version
|
|
158
|
-
version: '0'
|
|
159
145
|
description: This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program
|
|
160
146
|
email: info@elastic.co
|
|
161
147
|
executables: []
|
|
@@ -193,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
193
179
|
version: '0'
|
|
194
180
|
requirements: []
|
|
195
181
|
rubyforge_project:
|
|
196
|
-
rubygems_version: 2.
|
|
182
|
+
rubygems_version: 2.4.8
|
|
197
183
|
signing_key:
|
|
198
184
|
specification_version: 4
|
|
199
185
|
summary: This example input streams a string at a definable interval.
|