logstash-input-jdbc 2.1.0 → 2.1.1

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
  SHA1:
3
- metadata.gz: f9bab690eb90f270679aa61551938fa2bf7ee6de
4
- data.tar.gz: ef01a9593412b885252102358fde81cb50a268e2
3
+ metadata.gz: 6fc9b06fd127404a35d42af320ad90b37f0ff642
4
+ data.tar.gz: 21798f6ed0c0620f054acc6abe0c207211fadc70
5
5
  SHA512:
6
- metadata.gz: bfb164e27f19f96e41026ceaca231a62855aef0e1d9c4e38ab39f923d9d0059bb39361576a442c78fa6b9f618acb6df33dd196b581337b53fc3f26ac6b4f2d64
7
- data.tar.gz: 854657f5cecda124c91baf0342921b7cbca9e451957a33587cb670f189cb7dbf93312d3cfdd28634509d3a1858baeedc6f9a4c6a9827cb9fbc8a9f8ba3b08eb6
6
+ metadata.gz: bc1d4d90e171555d00334ab59ef67699bdf55e714557ef565a9b47d870b20d233f23fe7f0a48ed0025396ab822a9e18971d7eed1692027eac4971ced58f1ffb6
7
+ data.tar.gz: aeeb2afa34a2767d035c20e71c0efdd709f9df48988954761d064e542def704ba7c4ec8e52248187eb8df8847f6db1bfb5c60f081db2b1bd8709f6bb908210f3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 2.1.1
2
+ - [#44](https://github.com/logstash-plugins/logstash-input-jdbc/issues/44) add option to control the lowercase or not, of the column names.
3
+
1
4
  ## 2.1.0
2
5
  - [#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.
3
6
  - [#89](https://github.com/logstash-plugins/logstash-input-jdbc/issues/89) Set application timezone for cases where time fields in data have no timezone.
@@ -12,13 +12,13 @@ require "yaml" # persistence
12
12
  #
13
13
  # ==== Drivers
14
14
  #
15
- # This plugin does not come packaged with JDBC driver libraries. The desired
15
+ # This plugin does not come packaged with JDBC driver libraries. The desired
16
16
  # jdbc driver library must be explicitly passed in to the plugin using the
17
17
  # `jdbc_driver_library` configuration option.
18
- #
18
+ #
19
19
  # ==== Scheduling
20
20
  #
21
- # Input from this plugin can be scheduled to run periodically according to a specific
21
+ # Input from this plugin can be scheduled to run periodically according to a specific
22
22
  # schedule. This scheduling syntax is powered by https://github.com/jmettraux/rufus-scheduler[rufus-scheduler].
23
23
  # The syntax is cron-like with some extensions specific to Rufus (e.g. timezone support ).
24
24
  #
@@ -29,16 +29,16 @@ require "yaml" # persistence
29
29
  # | `0 * * * *` | will execute on the 0th minute of every hour every day.
30
30
  # | `0 6 * * * America/Chicago` | will execute at 6:00am (UTC/GMT -5) every day.
31
31
  # |==========================================================
32
- #
32
+ #
33
33
  #
34
34
  # Further documentation describing this syntax can be found https://github.com/jmettraux/rufus-scheduler#parsing-cronlines-and-time-strings[here].
35
35
  #
36
36
  # ==== State
37
37
  #
38
- # The plugin will persist the `sql_last_start` parameter in the form of a
39
- # metadata file stored in the configured `last_run_metadata_path`. Upon shutting down,
38
+ # The plugin will persist the `sql_last_start` parameter in the form of a
39
+ # metadata file stored in the configured `last_run_metadata_path`. Upon shutting down,
40
40
  # this file will be updated with the current value of `sql_last_start`. Next time
41
- # the pipeline starts up, this value will be updated by reading from the file. If
41
+ # the pipeline starts up, this value will be updated by reading from the file. If
42
42
  # `clean_run` is set to true, this value will be ignored and `sql_last_start` will be
43
43
  # set to Jan 1, 1970, as if no query has ever been executed.
44
44
  #
@@ -48,17 +48,17 @@ require "yaml" # persistence
48
48
  # results are pre-fetched at a time from the cursor into the client's cache
49
49
  # before retrieving more results from the result-set. This is configured in
50
50
  # this plugin using the `jdbc_fetch_size` configuration option. No fetch size
51
- # is set by default in this plugin, so the specific driver's default size will
51
+ # is set by default in this plugin, so the specific driver's default size will
52
52
  # be used.
53
53
  #
54
54
  # ==== Usage:
55
55
  #
56
56
  # Here is an example of setting up the plugin to fetch data from a MySQL database.
57
57
  # First, we place the appropriate JDBC driver library in our current
58
- # path (this can be placed anywhere on your filesystem). In this example, we connect to
58
+ # path (this can be placed anywhere on your filesystem). In this example, we connect to
59
59
  # the 'mydb' database using the user: 'mysql' and wish to input all rows in the 'songs'
60
- # table that match a specific artist. The following examples demonstrates a possible
61
- # Logstash configuration for this. The `schedule` option in this example will
60
+ # table that match a specific artist. The following examples demonstrates a possible
61
+ # Logstash configuration for this. The `schedule` option in this example will
62
62
  # instruct the plugin to execute this input statement on the minute, every minute.
63
63
  #
64
64
  # [source,ruby]
@@ -77,9 +77,9 @@ require "yaml" # persistence
77
77
  # ----------------------------------
78
78
  #
79
79
  # ==== Configuring SQL statement
80
- #
81
- # A sql statement is required for this input. This can be passed-in via a
82
- # statement option in the form of a string, or read from a file (`statement_filepath`). File
80
+ #
81
+ # A sql statement is required for this input. This can be passed-in via a
82
+ # statement option in the form of a string, or read from a file (`statement_filepath`). File
83
83
  # option is typically used when the SQL statement is large or cumbersome to supply in the config.
84
84
  # The file option only supports one SQL statement. The plugin will only accept one of the options.
85
85
  # It cannot read a statement from a file as well as from the `statement` configuration parameter.
@@ -99,7 +99,7 @@ class LogStash::Inputs::Jdbc < LogStash::Inputs::Base
99
99
  config_name "jdbc"
100
100
 
101
101
  # If undefined, Logstash will complain, even if codec is unused.
102
- default :codec, "plain"
102
+ default :codec, "plain"
103
103
 
104
104
  # Statement to execute
105
105
  #
@@ -137,6 +137,9 @@ class LogStash::Inputs::Jdbc < LogStash::Inputs::Base
137
137
  # Whether to save state or not in last_run_metadata_path
138
138
  config :record_last_run, :validate => :boolean, :default => true
139
139
 
140
+ # Whether to force the lowercasing of identifier fields
141
+ config :lowercase_column_names, :validate => :boolean, :default => true
142
+
140
143
  public
141
144
 
142
145
  def register
@@ -156,6 +156,11 @@ module LogStash::PluginMixins::Jdbc
156
156
  end
157
157
  @database.sql_log_level = @sql_log_level.to_sym
158
158
  @database.logger = @logger
159
+ if @lowercase_column_names
160
+ @database.identifier_output_method = :downcase
161
+ else
162
+ @database.identifier_output_method = :to_s
163
+ end
159
164
  @sql_last_start = Time.at(0).utc
160
165
  end # def prepare_jdbc_connection
161
166
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-input-jdbc'
3
- s.version = '2.1.0'
3
+ s.version = '2.1.1'
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/plugin install gemname. This gem is not a stand-alone program"
@@ -506,4 +506,39 @@ describe LogStash::Inputs::Jdbc do
506
506
  end
507
507
  end
508
508
 
509
+ describe "config option lowercase_column_names behaviour" do
510
+ let(:settings) { { "statement" => "SELECT * FROM ttt" } }
511
+ let(:events) { [] }
512
+
513
+ before do
514
+ db.create_table(:ttt) do
515
+ Integer(:num)
516
+ String(:somestring)
517
+ end
518
+ db[:ttt].insert(:num => 42, :somestring => "This is a string")
519
+ plugin.register
520
+ end
521
+
522
+ after do
523
+ plugin.stop
524
+ db.drop_table(:ttt)
525
+ end
526
+
527
+ context "when lowercase_column_names is on (default)" do
528
+ it "the field names are lower case" do
529
+ plugin.run(events)
530
+ expect(events.first.to_hash.keys.sort).to eq(
531
+ ["@timestamp", "@version","num", "somestring"])
532
+ end
533
+ end
534
+
535
+ context "when lowercase_column_names is off" do
536
+ let(:settings) { { "statement" => "SELECT * FROM ttt", "lowercase_column_names" => false } }
537
+ it "the field names are UPPER case (natural for Derby DB)" do
538
+ plugin.run(events)
539
+ expect(events.first.to_hash.keys.sort).to eq(
540
+ ["@timestamp", "@version","NUM", "SOMESTRING"])
541
+ end
542
+ end
543
+ end
509
544
  end
metadata CHANGED
@@ -1,161 +1,161 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-jdbc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-09 00:00:00.000000000 Z
11
+ date: 2015-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- requirement: !ruby/object:Gem::Requirement
14
+ name: logstash-core
15
+ version_requirements: !ruby/object:Gem::Requirement
15
16
  requirements:
16
- - - ">="
17
+ - - '>='
17
18
  - !ruby/object:Gem::Version
18
19
  version: 2.0.0.beta2
19
- - - "<"
20
+ - - <
20
21
  - !ruby/object:Gem::Version
21
22
  version: 3.0.0
22
- name: logstash-core
23
- prerelease: false
24
- type: :runtime
25
- version_requirements: !ruby/object:Gem::Requirement
23
+ requirement: !ruby/object:Gem::Requirement
26
24
  requirements:
27
- - - ">="
25
+ - - '>='
28
26
  - !ruby/object:Gem::Version
29
27
  version: 2.0.0.beta2
30
- - - "<"
28
+ - - <
31
29
  - !ruby/object:Gem::Version
32
30
  version: 3.0.0
31
+ prerelease: false
32
+ type: :runtime
33
33
  - !ruby/object:Gem::Dependency
34
+ name: logstash-codec-plain
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
34
40
  requirement: !ruby/object:Gem::Requirement
35
41
  requirements:
36
- - - ">="
42
+ - - '>='
37
43
  - !ruby/object:Gem::Version
38
44
  version: '0'
39
- name: logstash-codec-plain
40
45
  prerelease: false
41
46
  type: :runtime
47
+ - !ruby/object:Gem::Dependency
48
+ name: sequel
42
49
  version_requirements: !ruby/object:Gem::Requirement
43
50
  requirements:
44
- - - ">="
51
+ - - '>='
45
52
  - !ruby/object:Gem::Version
46
53
  version: '0'
47
- - !ruby/object:Gem::Dependency
48
54
  requirement: !ruby/object:Gem::Requirement
49
55
  requirements:
50
- - - ">="
56
+ - - '>='
51
57
  - !ruby/object:Gem::Version
52
58
  version: '0'
53
- name: sequel
54
59
  prerelease: false
55
60
  type: :runtime
61
+ - !ruby/object:Gem::Dependency
62
+ name: tzinfo
56
63
  version_requirements: !ruby/object:Gem::Requirement
57
64
  requirements:
58
- - - ">="
65
+ - - '>='
59
66
  - !ruby/object:Gem::Version
60
67
  version: '0'
61
- - !ruby/object:Gem::Dependency
62
68
  requirement: !ruby/object:Gem::Requirement
63
69
  requirements:
64
- - - ">="
70
+ - - '>='
65
71
  - !ruby/object:Gem::Version
66
72
  version: '0'
67
- name: tzinfo
68
73
  prerelease: false
69
74
  type: :runtime
75
+ - !ruby/object:Gem::Dependency
76
+ name: tzinfo-data
70
77
  version_requirements: !ruby/object:Gem::Requirement
71
78
  requirements:
72
- - - ">="
79
+ - - '>='
73
80
  - !ruby/object:Gem::Version
74
81
  version: '0'
75
- - !ruby/object:Gem::Dependency
76
82
  requirement: !ruby/object:Gem::Requirement
77
83
  requirements:
78
- - - ">="
84
+ - - '>='
79
85
  - !ruby/object:Gem::Version
80
86
  version: '0'
81
- name: tzinfo-data
82
87
  prerelease: false
83
88
  type: :runtime
89
+ - !ruby/object:Gem::Dependency
90
+ name: rufus-scheduler
84
91
  version_requirements: !ruby/object:Gem::Requirement
85
92
  requirements:
86
- - - ">="
93
+ - - '>='
87
94
  - !ruby/object:Gem::Version
88
95
  version: '0'
89
- - !ruby/object:Gem::Dependency
90
96
  requirement: !ruby/object:Gem::Requirement
91
97
  requirements:
92
- - - ">="
98
+ - - '>='
93
99
  - !ruby/object:Gem::Version
94
100
  version: '0'
95
- name: rufus-scheduler
96
101
  prerelease: false
97
102
  type: :runtime
103
+ - !ruby/object:Gem::Dependency
104
+ name: logstash-devutils
98
105
  version_requirements: !ruby/object:Gem::Requirement
99
106
  requirements:
100
- - - ">="
107
+ - - '>='
101
108
  - !ruby/object:Gem::Version
102
109
  version: '0'
103
- - !ruby/object:Gem::Dependency
104
110
  requirement: !ruby/object:Gem::Requirement
105
111
  requirements:
106
- - - ">="
112
+ - - '>='
107
113
  - !ruby/object:Gem::Version
108
114
  version: '0'
109
- name: logstash-devutils
110
115
  prerelease: false
111
116
  type: :development
117
+ - !ruby/object:Gem::Dependency
118
+ name: timecop
112
119
  version_requirements: !ruby/object:Gem::Requirement
113
120
  requirements:
114
- - - ">="
121
+ - - '>='
115
122
  - !ruby/object:Gem::Version
116
123
  version: '0'
117
- - !ruby/object:Gem::Dependency
118
124
  requirement: !ruby/object:Gem::Requirement
119
125
  requirements:
120
- - - ">="
126
+ - - '>='
121
127
  - !ruby/object:Gem::Version
122
128
  version: '0'
123
- name: timecop
124
129
  prerelease: false
125
130
  type: :development
131
+ - !ruby/object:Gem::Dependency
132
+ name: jdbc-derby
126
133
  version_requirements: !ruby/object:Gem::Requirement
127
134
  requirements:
128
- - - ">="
135
+ - - '>='
129
136
  - !ruby/object:Gem::Version
130
137
  version: '0'
131
- - !ruby/object:Gem::Dependency
132
138
  requirement: !ruby/object:Gem::Requirement
133
139
  requirements:
134
- - - ">="
140
+ - - '>='
135
141
  - !ruby/object:Gem::Version
136
142
  version: '0'
137
- name: jdbc-derby
138
143
  prerelease: false
139
144
  type: :development
145
+ - !ruby/object:Gem::Dependency
146
+ name: docker-api
140
147
  version_requirements: !ruby/object:Gem::Requirement
141
148
  requirements:
142
- - - ">="
149
+ - - '>='
143
150
  - !ruby/object:Gem::Version
144
151
  version: '0'
145
- - !ruby/object:Gem::Dependency
146
152
  requirement: !ruby/object:Gem::Requirement
147
153
  requirements:
148
- - - ">="
154
+ - - '>='
149
155
  - !ruby/object:Gem::Version
150
156
  version: '0'
151
- name: docker-api
152
157
  prerelease: false
153
158
  type: :development
154
- version_requirements: !ruby/object:Gem::Requirement
155
- requirements:
156
- - - ">="
157
- - !ruby/object:Gem::Version
158
- version: '0'
159
159
  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
160
160
  email: info@elastic.co
161
161
  executables: []
@@ -183,12 +183,12 @@ require_paths:
183
183
  - lib
184
184
  required_ruby_version: !ruby/object:Gem::Requirement
185
185
  requirements:
186
- - - ">="
186
+ - - '>='
187
187
  - !ruby/object:Gem::Version
188
188
  version: '0'
189
189
  required_rubygems_version: !ruby/object:Gem::Requirement
190
190
  requirements:
191
- - - ">="
191
+ - - '>='
192
192
  - !ruby/object:Gem::Version
193
193
  version: '0'
194
194
  requirements: []