logstash-integration-jdbc 5.5.3 → 5.6.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a28e2a3a37342bc631ed300da7fa687e99fc879d8cc599669d64e2cfc6418177
4
- data.tar.gz: 38b675462f29af81148dbdcc58144a2e3df932b6c6a44825b580a3468ac90acb
3
+ metadata.gz: a562598bdb5d577eb9dc0cd8d419dcdf26d22e04e07446dfc44cf22e877ff0f4
4
+ data.tar.gz: ab6adff6a86ec1bebdc887e1ec874520bf24256330d6b7a0c74be764d278541c
5
5
  SHA512:
6
- metadata.gz: b3af9d1d0c7ddc88b8102d7fafb96a9c379a734266698a3136e9e9522f640f64f4f019ea5820c9bc382a460df5f47f2fc62bb6cf8c3ad47ad84f5069710831cd
7
- data.tar.gz: 41a6e399b350068d1ed337c158b94f9457f0ace2f31588888db8c99b9e20a39f7fe0f06ab4e809cd01c7a635c9ede2a00629aa1ecf04b9cd86951fdda5c9a828
6
+ metadata.gz: 0e262fa20df3ee0cc8e1cf9f9ec8f68c0529f571166718e9d9dfeb050712cd3760b903c1d116cdebe1067352708e7bff5b04acdb55dca3112a5cb136831ebedc
7
+ data.tar.gz: 8c13ff927125d49032b6339d08caa95c0b18b1669de3bf8dfbd0432c8a7543c0d9ea92260b2fa6d79e5166aa3756a60a981b49ad59b6ee4710d7794ebf5fc759
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 5.6.0
2
+ - Support other rufus scheduling options in JDBC Input [#183](https://github.com/logstash-plugins/logstash-integration-jdbc/pull/183)
3
+
1
4
  ## 5.5.3
2
5
  - [DOC] Rework inline comment to a callout in preparation for upcoming MD conversion [#181](https://github.com/logstash-plugins/logstash-integration-jdbc/pull/181)
3
6
 
@@ -41,9 +41,9 @@ options for more info.
41
41
 
42
42
  Input from this plugin can be scheduled to run periodically according to a specific
43
43
  schedule. This scheduling syntax is powered by https://github.com/jmettraux/rufus-scheduler[rufus-scheduler].
44
- The syntax is cron-like with some extensions specific to Rufus (e.g. timezone support ).
44
+ The syntax is either cron-like with some extensions specific to Rufus (e.g. timezone support ) if using the `schedule` option or periodic when using `period` or `interval` option.
45
45
 
46
- Examples:
46
+ Examples for `schedule`:
47
47
 
48
48
  |==========================================================
49
49
  | `* 5 * 1-3 *` | will execute every minute of 5am every day of January through March.
@@ -51,9 +51,21 @@ Examples:
51
51
  | `0 6 * * * America/Chicago` | will execute at 6:00am (UTC/GMT -5) every day.
52
52
  |==========================================================
53
53
 
54
+ Examples for `period` or `interval`:
55
+
56
+ |==========================================================
57
+ | `1m` | will execute every minute
58
+ | `3h10m` | will execute every three hours and 10 minutes
59
+ |==========================================================
54
60
 
55
61
  Further documentation describing this syntax can be found https://github.com/jmettraux/rufus-scheduler#parsing-cronlines-and-time-strings[here].
56
62
 
63
+ `interval` jobs trigger, execute and then trigger again after the interval elapsed.
64
+
65
+ `period` jobs try to trigger following the frequency they were scheduled with.
66
+
67
+ You can only use one of `interval`, `period` or `schedule` at the same time.
68
+
57
69
  ==== State
58
70
 
59
71
  The plugin will persist the `sql_last_value` parameter in the form of a
@@ -212,6 +224,7 @@ This plugin supports the following configuration options plus the <<plugins-{typ
212
224
  | <<plugins-{type}s-{plugin}-columns_charset>> |<<hash,hash>>|No
213
225
  | <<plugins-{type}s-{plugin}-connection_retry_attempts>> |<<number,number>>|No
214
226
  | <<plugins-{type}s-{plugin}-connection_retry_attempts_wait_time>> |<<number,number>>|No
227
+ | <<plugins-{type}s-{plugin}-interval>> |<<string,string>>|No
215
228
  | <<plugins-{type}s-{plugin}-jdbc_connection_string>> |<<string,string>>|Yes
216
229
  | <<plugins-{type}s-{plugin}-jdbc_default_timezone>> |<<string,string>>|No
217
230
  | <<plugins-{type}s-{plugin}-jdbc_driver_class>> |<<string,string>>|Yes
@@ -229,6 +242,7 @@ This plugin supports the following configuration options plus the <<plugins-{typ
229
242
  | <<plugins-{type}s-{plugin}-last_run_metadata_path>> |<<string,string>>|No
230
243
  | <<plugins-{type}s-{plugin}-lowercase_column_names>> |<<boolean,boolean>>|No
231
244
  | <<plugins-{type}s-{plugin}-parameters>> |<<hash,hash>>|No
245
+ | <<plugins-{type}s-{plugin}-period>> |<<string,string>>|No
232
246
  | <<plugins-{type}s-{plugin}-plugin_timezone>> |<<string,string>>, one of `["local", "utc"]`|No
233
247
  | <<plugins-{type}s-{plugin}-prepared_statement_bind_values>> |<<array,array>>|No
234
248
  | <<plugins-{type}s-{plugin}-prepared_statement_name>> |<<string,string>>|No
@@ -298,6 +312,16 @@ Maximum number of times to try connecting to database
298
312
 
299
313
  Number of seconds to sleep between connection attempts
300
314
 
315
+ [id="plugins-{type}s-{plugin}-interval"]
316
+ ===== `interval`
317
+
318
+ * Value type is <<string,string>>
319
+ * There is no default value for this setting.
320
+
321
+ This takes a string in the form of `1h`, `1m`, to denote a time interval. `interval` jobs trigger, execute and trigger again after the provided time interval has elapsed.
322
+
323
+ There is no schedule by default. If no scheduling statement is given, then the statement is run exactly once.
324
+
301
325
  [id="plugins-{type}s-{plugin}-jdbc_connection_string"]
302
326
  ===== `jdbc_connection_string`
303
327
 
@@ -538,6 +562,16 @@ Whether to force the lowercasing of identifier fields
538
562
 
539
563
  Hash of query parameter, for example `{ "target_id" => "321" }`
540
564
 
565
+ [id="plugins-{type}s-{plugin}-period"]
566
+ ===== `period`
567
+
568
+ * Value type is <<string,string>>
569
+ * There is no default value for this setting.
570
+
571
+ This takes a string in the form of `1h`, `1m`, to denote a time interval. `period` jobs try hard to trigger following the frequency they were scheduled with.
572
+
573
+ There is no schedule by default. If no scheduling statement is given, then the statement is run exactly once.
574
+
541
575
  [id="plugins-{type}s-{plugin}-prepared_statement_bind_values"]
542
576
  ===== `prepared_statement_bind_values`
543
577
 
@@ -568,11 +602,9 @@ Whether to save state or not in <<plugins-{type}s-{plugin}-last_run_metadata_pat
568
602
  * Value type is <<string,string>>
569
603
  * There is no default value for this setting.
570
604
 
571
- Schedule of when to periodically run statement, in Cron format
572
- for example: "* * * * *" (execute query every minute, on the minute)
605
+ Schedule of when to periodically run statement, in Cron format for example: "* * * * *" (execute query every minute, on the minute)
573
606
 
574
- There is no schedule by default. If no schedule is given, then the statement is run
575
- exactly once.
607
+ There is no schedule by default. If no scheduling statement is given, then the statement is run exactly once.
576
608
 
577
609
  [id="plugins-{type}s-{plugin}-sequel_opts"]
578
610
  ===== `sequel_opts`
@@ -180,6 +180,20 @@ module LogStash module Inputs class Jdbc < LogStash::Inputs::Base
180
180
  # exactly once.
181
181
  config :schedule, :validate => :string
182
182
 
183
+ # Interval of how soon to run statement again after completion
184
+ # for example: "1m" (execute again 1 minute after completion)
185
+ #
186
+ # There is no interval by default. If no interval is given, then the statement is run
187
+ # exactly once.
188
+ config :interval, :validate => :string
189
+
190
+ # Start the job periodically after time elapsed
191
+ # for example: "1m" (execute query every minute)
192
+ #
193
+ # There is no period by default. If no period is given, then the statement is run
194
+ # exactly once.
195
+ config :period, :validate => :string
196
+
183
197
  # Path to file with last run time.
184
198
  # The default will write file to `<path.data>/plugins/inputs/jdbc/logstash_jdbc_last_run`
185
199
  # NOTE: it must be a file path and not a directory path
@@ -241,6 +255,11 @@ module LogStash module Inputs class Jdbc < LogStash::Inputs::Base
241
255
  def register
242
256
  @logger = self.logger
243
257
 
258
+ if [@interval, @schedule, @period].compact.size > 1
259
+ raise LogStash::ConfigurationError.new("Use only one of: interval, period, schedule.")
260
+ end
261
+
262
+
244
263
  if @record_last_run
245
264
  if @last_run_metadata_path.nil?
246
265
  logstash_data_path = LogStash::SETTINGS.get_value("path.data")
@@ -322,6 +341,12 @@ module LogStash module Inputs class Jdbc < LogStash::Inputs::Base
322
341
  # scheduler input thread name example: "[my-oracle]|input|jdbc|scheduler"
323
342
  scheduler.cron(@schedule) { execute_query(queue) }
324
343
  scheduler.join
344
+ elsif @interval
345
+ scheduler.interval(@interval) { execute_query(queue) }
346
+ scheduler.join
347
+ elsif @period
348
+ scheduler.every(@period) { execute_query(queue) }
349
+ scheduler.join
325
350
  else
326
351
  execute_query(queue)
327
352
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-integration-jdbc'
3
- s.version = '5.5.3'
3
+ s.version = '5.6.0'
4
4
  s.licenses = ['Apache License (2.0)']
5
5
  s.summary = "Integration with JDBC - input and filter plugins"
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"
@@ -228,6 +228,33 @@ describe LogStash::Inputs::Jdbc do
228
228
  end
229
229
  end
230
230
 
231
+ describe "scheduling options" do
232
+ let(:settings) { super().merge("statement" => "SELECT :num_param as num_param FROM SYSIBM.SYSDUMMY1") }
233
+ scheduling_options = ["interval", "schedule", "period"]
234
+ scheduling_options.combination(2).each do |option1, option2|
235
+ context "when using '#{option1}' and '#{option2}' at the same time" do
236
+ let(:settings) { super().merge(option1 => 'a', option2 => 'b') }
237
+ it "raises a configuration error" do
238
+ expect { plugin.register }.to raise_error(LogStash::ConfigurationError, /Use only one/)
239
+ end
240
+ end
241
+ end
242
+ context "when using 'schedule', 'period' and 'interval' at the same time" do
243
+ let(:settings) { super().merge("interval" => "a", "period" => "b", "schedule" => "c") }
244
+ it "raises a configuration error" do
245
+ expect { plugin.register }.to raise_error(LogStash::ConfigurationError, /Use only one/)
246
+ end
247
+ end
248
+ scheduling_options.each do |option|
249
+ context "when using only '#{option}'" do
250
+ let(:settings) { super().merge(option => "a") }
251
+ it "does not raise a configuration error" do
252
+ expect { plugin.register }.to_not raise_error
253
+ end
254
+ end
255
+ end
256
+ end
257
+
231
258
  context "when scheduling" do
232
259
  let(:settings) { {"statement" => "SELECT 1 as num_param FROM SYSIBM.SYSDUMMY1", "schedule" => "* * * * * UTC"} }
233
260
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-integration-jdbc
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.5.3
4
+ version: 5.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-07 00:00:00.000000000 Z
11
+ date: 2025-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement