logstash-output-cassandra 0.9.0 → 0.9.1

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
  SHA1:
3
- metadata.gz: eb924301f2fb18274dadf7937c5fb10ddab91a80
4
- data.tar.gz: d05bf1803112c866ffdc2ac13d5a7f4116709f31
3
+ metadata.gz: c9302d3a9e13a5a2d80d1b228d9741785599bffc
4
+ data.tar.gz: 9c35b7e36936512df5ab046c49a42152deacb522
5
5
  SHA512:
6
- metadata.gz: ad63bb3d2685b22ec636c0af391689b4353231f448b2806bb05c2617dfa2cfcc391772ba7d1b23c921eccaad1281c63f7ccd080ba3d8463299d14df9f01a029d
7
- data.tar.gz: 1dcda642fb5e9ab2f26930810ecc8ef99253a0cea977fb242823892a50e38fcd1025f17dc6a6ef42a44d6d0505c663d3293271e6e57a41d8846b865f52de0cad
6
+ metadata.gz: 0a6fd4c289c65ada58ff2939e6d1eb722a7e05afb0e0ab9ccaa495ac15de453c544cecb63209e4e2bdcbd5760d6ceba6af80e5c4f01b58b61a61bfd865ea188e
7
+ data.tar.gz: 64d572b84c1b1370dbb4c7cad7af6383f61d934d477c76041463d87d8aa622abff183efd121c0973c50b3a3d5029bd5d8c74d3b5ed8df2f88607f2e28d097f2f
data/LICENSE CHANGED
@@ -1,5 +1,4 @@
1
- <<<<<<< HEAD
2
- Copyright (c) 2012-2015 Elasticsearch <http://www.elasticsearch.org>
1
+ Copyright (c) 2016 PerimeterX <http://www.perimeterx.com>
3
2
 
4
3
  Licensed under the Apache License, Version 2.0 (the "License");
5
4
  you may not use this file except in compliance with the License.
@@ -12,207 +11,3 @@ distributed under the License is distributed on an "AS IS" BASIS,
12
11
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
12
  See the License for the specific language governing permissions and
14
13
  limitations under the License.
15
- =======
16
- Apache License
17
- Version 2.0, January 2004
18
- http://www.apache.org/licenses/
19
-
20
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
21
-
22
- 1. Definitions.
23
-
24
- "License" shall mean the terms and conditions for use, reproduction,
25
- and distribution as defined by Sections 1 through 9 of this document.
26
-
27
- "Licensor" shall mean the copyright owner or entity authorized by
28
- the copyright owner that is granting the License.
29
-
30
- "Legal Entity" shall mean the union of the acting entity and all
31
- other entities that control, are controlled by, or are under common
32
- control with that entity. For the purposes of this definition,
33
- "control" means (i) the power, direct or indirect, to cause the
34
- direction or management of such entity, whether by contract or
35
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
36
- outstanding shares, or (iii) beneficial ownership of such entity.
37
-
38
- "You" (or "Your") shall mean an individual or Legal Entity
39
- exercising permissions granted by this License.
40
-
41
- "Source" form shall mean the preferred form for making modifications,
42
- including but not limited to software source code, documentation
43
- source, and configuration files.
44
-
45
- "Object" form shall mean any form resulting from mechanical
46
- transformation or translation of a Source form, including but
47
- not limited to compiled object code, generated documentation,
48
- and conversions to other media types.
49
-
50
- "Work" shall mean the work of authorship, whether in Source or
51
- Object form, made available under the License, as indicated by a
52
- copyright notice that is included in or attached to the work
53
- (an example is provided in the Appendix below).
54
-
55
- "Derivative Works" shall mean any work, whether in Source or Object
56
- form, that is based on (or derived from) the Work and for which the
57
- editorial revisions, annotations, elaborations, or other modifications
58
- represent, as a whole, an original work of authorship. For the purposes
59
- of this License, Derivative Works shall not include works that remain
60
- separable from, or merely link (or bind by name) to the interfaces of,
61
- the Work and Derivative Works thereof.
62
-
63
- "Contribution" shall mean any work of authorship, including
64
- the original version of the Work and any modifications or additions
65
- to that Work or Derivative Works thereof, that is intentionally
66
- submitted to Licensor for inclusion in the Work by the copyright owner
67
- or by an individual or Legal Entity authorized to submit on behalf of
68
- the copyright owner. For the purposes of this definition, "submitted"
69
- means any form of electronic, verbal, or written communication sent
70
- to the Licensor or its representatives, including but not limited to
71
- communication on electronic mailing lists, source code control systems,
72
- and issue tracking systems that are managed by, or on behalf of, the
73
- Licensor for the purpose of discussing and improving the Work, but
74
- excluding communication that is conspicuously marked or otherwise
75
- designated in writing by the copyright owner as "Not a Contribution."
76
-
77
- "Contributor" shall mean Licensor and any individual or Legal Entity
78
- on behalf of whom a Contribution has been received by Licensor and
79
- subsequently incorporated within the Work.
80
-
81
- 2. Grant of Copyright License. Subject to the terms and conditions of
82
- this License, each Contributor hereby grants to You a perpetual,
83
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
84
- copyright license to reproduce, prepare Derivative Works of,
85
- publicly display, publicly perform, sublicense, and distribute the
86
- Work and such Derivative Works in Source or Object form.
87
-
88
- 3. Grant of Patent License. Subject to the terms and conditions of
89
- this License, each Contributor hereby grants to You a perpetual,
90
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
91
- (except as stated in this section) patent license to make, have made,
92
- use, offer to sell, sell, import, and otherwise transfer the Work,
93
- where such license applies only to those patent claims licensable
94
- by such Contributor that are necessarily infringed by their
95
- Contribution(s) alone or by combination of their Contribution(s)
96
- with the Work to which such Contribution(s) was submitted. If You
97
- institute patent litigation against any entity (including a
98
- cross-claim or counterclaim in a lawsuit) alleging that the Work
99
- or a Contribution incorporated within the Work constitutes direct
100
- or contributory patent infringement, then any patent licenses
101
- granted to You under this License for that Work shall terminate
102
- as of the date such litigation is filed.
103
-
104
- 4. Redistribution. You may reproduce and distribute copies of the
105
- Work or Derivative Works thereof in any medium, with or without
106
- modifications, and in Source or Object form, provided that You
107
- meet the following conditions:
108
-
109
- (a) You must give any other recipients of the Work or
110
- Derivative Works a copy of this License; and
111
-
112
- (b) You must cause any modified files to carry prominent notices
113
- stating that You changed the files; and
114
-
115
- (c) You must retain, in the Source form of any Derivative Works
116
- that You distribute, all copyright, patent, trademark, and
117
- attribution notices from the Source form of the Work,
118
- excluding those notices that do not pertain to any part of
119
- the Derivative Works; and
120
-
121
- (d) If the Work includes a "NOTICE" text file as part of its
122
- distribution, then any Derivative Works that You distribute must
123
- include a readable copy of the attribution notices contained
124
- within such NOTICE file, excluding those notices that do not
125
- pertain to any part of the Derivative Works, in at least one
126
- of the following places: within a NOTICE text file distributed
127
- as part of the Derivative Works; within the Source form or
128
- documentation, if provided along with the Derivative Works; or,
129
- within a display generated by the Derivative Works, if and
130
- wherever such third-party notices normally appear. The contents
131
- of the NOTICE file are for informational purposes only and
132
- do not modify the License. You may add Your own attribution
133
- notices within Derivative Works that You distribute, alongside
134
- or as an addendum to the NOTICE text from the Work, provided
135
- that such additional attribution notices cannot be construed
136
- as modifying the License.
137
-
138
- You may add Your own copyright statement to Your modifications and
139
- may provide additional or different license terms and conditions
140
- for use, reproduction, or distribution of Your modifications, or
141
- for any such Derivative Works as a whole, provided Your use,
142
- reproduction, and distribution of the Work otherwise complies with
143
- the conditions stated in this License.
144
-
145
- 5. Submission of Contributions. Unless You explicitly state otherwise,
146
- any Contribution intentionally submitted for inclusion in the Work
147
- by You to the Licensor shall be under the terms and conditions of
148
- this License, without any additional terms or conditions.
149
- Notwithstanding the above, nothing herein shall supersede or modify
150
- the terms of any separate license agreement you may have executed
151
- with Licensor regarding such Contributions.
152
-
153
- 6. Trademarks. This License does not grant permission to use the trade
154
- names, trademarks, service marks, or product names of the Licensor,
155
- except as required for reasonable and customary use in describing the
156
- origin of the Work and reproducing the content of the NOTICE file.
157
-
158
- 7. Disclaimer of Warranty. Unless required by applicable law or
159
- agreed to in writing, Licensor provides the Work (and each
160
- Contributor provides its Contributions) on an "AS IS" BASIS,
161
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
162
- implied, including, without limitation, any warranties or conditions
163
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
164
- PARTICULAR PURPOSE. You are solely responsible for determining the
165
- appropriateness of using or redistributing the Work and assume any
166
- risks associated with Your exercise of permissions under this License.
167
-
168
- 8. Limitation of Liability. In no event and under no legal theory,
169
- whether in tort (including negligence), contract, or otherwise,
170
- unless required by applicable law (such as deliberate and grossly
171
- negligent acts) or agreed to in writing, shall any Contributor be
172
- liable to You for damages, including any direct, indirect, special,
173
- incidental, or consequential damages of any character arising as a
174
- result of this License or out of the use or inability to use the
175
- Work (including but not limited to damages for loss of goodwill,
176
- work stoppage, computer failure or malfunction, or any and all
177
- other commercial damages or losses), even if such Contributor
178
- has been advised of the possibility of such damages.
179
-
180
- 9. Accepting Warranty or Additional Liability. While redistributing
181
- the Work or Derivative Works thereof, You may choose to offer,
182
- and charge a fee for, acceptance of support, warranty, indemnity,
183
- or other liability obligations and/or rights consistent with this
184
- License. However, in accepting such obligations, You may act only
185
- on Your own behalf and on Your sole responsibility, not on behalf
186
- of any other Contributor, and only if You agree to indemnify,
187
- defend, and hold each Contributor harmless for any liability
188
- incurred by, or claims asserted against, such Contributor by reason
189
- of your accepting any such warranty or additional liability.
190
-
191
- END OF TERMS AND CONDITIONS
192
-
193
- APPENDIX: How to apply the Apache License to your work.
194
-
195
- To apply the Apache License to your work, attach the following
196
- boilerplate notice, with the fields enclosed by brackets "{}"
197
- replaced with your own identifying information. (Don't include
198
- the brackets!) The text should be enclosed in the appropriate
199
- comment syntax for the file format. We also recommend that a
200
- file or class name and description of purpose be included on the
201
- same "printed page" as the copyright notice for easier
202
- identification within third-party archives.
203
-
204
- Copyright {yyyy} {name of copyright owner}
205
-
206
- Licensed under the Apache License, Version 2.0 (the "License");
207
- you may not use this file except in compliance with the License.
208
- You may obtain a copy of the License at
209
-
210
- http://www.apache.org/licenses/LICENSE-2.0
211
-
212
- Unless required by applicable law or agreed to in writing, software
213
- distributed under the License is distributed on an "AS IS" BASIS,
214
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
215
- See the License for the specific language governing permissions and
216
- limitations under the License.
217
-
218
- >>>>>>> 56f47bec0cc3d3230ae48792e7ac094823872298
data/README.md CHANGED
@@ -110,12 +110,17 @@ Edit Logstash Gemfile and add the local plugin path, for example:
110
110
  ```
111
111
  gem "logstash-output-cassandra", :path => "/your/local/logstash-output-cassandra"
112
112
  ```
113
-
114
- Install plugin
113
+ And install by executing:
115
114
  ```
116
115
  bin/plugin install --no-verify
117
116
  ```
118
- Run Logstash with the plugin
117
+
118
+ Or install plugin from RubyGems:
119
+ ```
120
+ bin/plugin install logstash-output-cassandra
121
+ ```
122
+
123
+ And then run Logstash with the plugin:
119
124
  ```
120
125
  bin/logstash -e 'output {cassandra {}}'
121
126
  ```
@@ -40,6 +40,8 @@ class LogStash::Outputs::CassandraOutput < LogStash::Outputs::Base
40
40
  # An optional hash describing how / what to transform / filter from the original event
41
41
  # Each key is expected to be of the form { event_key => "..." column_name => "..." cassandra_type => "..." }
42
42
  # Event level processing (e.g. %{[key]}) is supported for all three
43
+ # In case you only want to do string expansion (e.g. in the case of adding event specific dates) you can add the expansion_only key with a value of true
44
+ # Example: using { event_key => "%{+yyyyMMddHH}" column_name => "date" expansion_only => true } will result in a date column with a string of the specified format
43
45
  config :filter_transform, :validate => :array, :default => []
44
46
 
45
47
  # An optional string which points to the event specific location from which to pull the filter_transform definition
@@ -17,18 +17,22 @@ module LogStash; module Outputs; module Cassandra
17
17
 
18
18
  def parse(event)
19
19
  action = {}
20
- action['table'] = event.sprintf(@table)
21
- filter_transform = get_filter_transform(event)
22
- if filter_transform
23
- action['data'] = {}
24
- filter_transform.each { |filter|
25
- add_event_value_from_filter_to_action(event, filter, action)
26
- }
27
- else
28
- add_event_data_using_configured_hints(event, action)
20
+ begin
21
+ action['table'] = event.sprintf(@table)
22
+ filter_transform = get_filter_transform(event)
23
+ if filter_transform
24
+ action['data'] = {}
25
+ filter_transform.each { |filter|
26
+ add_event_value_from_filter_to_action(event, filter, action)
27
+ }
28
+ else
29
+ add_event_data_using_configured_hints(event, action)
30
+ end
31
+ @logger.debug('event parsed to action', :action => action)
32
+ rescue Exception => e
33
+ @logger.error('failed parsing event', :event => event, :error => e)
34
+ action = nil
29
35
  end
30
-
31
- @logger.debug('event parsed to action', :action => action)
32
36
  action
33
37
  end
34
38
 
@@ -57,8 +57,10 @@ module LogStash; module Outputs; module Cassandra
57
57
  remaining_queries = Queue.new
58
58
  actions.each do |action|
59
59
  begin
60
- query = get_query(action)
61
- remaining_queries << { :query => query, :arguments => action['data'].values }
60
+ if action
61
+ query = get_query(action)
62
+ remaining_queries << { :query => query, :arguments => action['data'].values }
63
+ end
62
64
  rescue Exception => e
63
65
  @logger.error('Failed to prepare query', :action => action, :exception => e, :backtrace => e.backtrace)
64
66
  end
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-output-cassandra'
4
- s.version = '0.9.0'
4
+ s.version = '0.9.1'
5
5
  s.licenses = [ 'Apache License (2.0)' ]
6
6
  s.summary = 'Store events into Cassandra'
7
7
  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'
@@ -40,7 +40,7 @@ RSpec.describe LogStash::Outputs::Cassandra::EventParser do
40
40
  describe 'filter transforms' do
41
41
  describe 'from config' do
42
42
  describe 'malformed configurations' do
43
- it 'fails if the transform has no event_data setting' do
43
+ it 'fails if the transform has no event_key setting' do
44
44
  expect { sut.new(default_opts.update({ 'filter_transform' => [{ 'column_name' => '' }] })) }.to raise_error(/item is incorrectly configured/)
45
45
  end
46
46
 
@@ -170,9 +170,10 @@ RSpec.describe LogStash::Outputs::Cassandra::EventParser do
170
170
  options = default_opts.update({ 'filter_transform' => [{ 'event_key' => 'a_field', 'column_name' => 'a_column', 'cassandra_type' => 'what?!' }] })
171
171
  sut_instance = sut.new(options)
172
172
  sample_event['a_field'] = 'a_value'
173
- expect(options['logger']).to(receive(:error))
173
+ expect(options['logger']).to(receive(:error)).at_least(:once)
174
174
 
175
- expect { sut_instance.parse(sample_event) }.to raise_error(/Cannot convert/)
175
+ result = sut_instance.parse(sample_event)
176
+ expect(result).to be_nil
176
177
  end
177
178
  end
178
179
  end
@@ -238,21 +239,23 @@ RSpec.describe LogStash::Outputs::Cassandra::EventParser do
238
239
  it 'fails for unknown hint types' do
239
240
  options = default_opts.update({ 'hints' => { 'a_field' => 'not_a_real_type' } })
240
241
  sut_instance = sut.new(options)
241
- expect(options['logger']).to(receive(:error))
242
-
242
+ expect(options['logger']).to(receive(:error)).at_least(:once)
243
243
  sample_event['a_field'] = 'a value'
244
244
 
245
- expect { sut_instance.parse(sample_event) }.to raise_error(/Cannot convert/)
245
+ result = sut_instance.parse(sample_event)
246
+
247
+ expect(result).to be_nil
246
248
  end
247
249
 
248
250
  it 'fails for unsuccessful hint conversion' do
249
251
  options = default_opts.update({ 'hints' => { 'a_field' => 'int' } })
250
- expect(options['logger']).to(receive(:error))
251
-
252
+ expect(options['logger']).to(receive(:error)).at_least(:once)
252
253
  sut_instance = sut.new(options)
253
-
254
254
  sample_event['a_field'] = 'i am not an int!!!'
255
- expect { sut_instance.parse(sample_event) }.to raise_error(/Cannot convert/)
255
+
256
+ result = sut_instance.parse(sample_event)
257
+
258
+ expect(result).to be_nil
256
259
  end
257
260
  end
258
261
 
@@ -297,8 +300,11 @@ RSpec.describe LogStash::Outputs::Cassandra::EventParser do
297
300
  options = default_opts.update({ 'ignore_bad_values' => true, 'hints' => { 'a_field' => 'map<float>' } })
298
301
  sut_instance = sut.new(options)
299
302
  sample_event['a_field'] = 'i am not a set'
303
+ expect(options['logger']).to(receive(:error))
304
+
305
+ result = sut_instance.parse(sample_event)
300
306
 
301
- expect { sut_instance.parse(sample_event) }.to raise_error ArgumentError
307
+ expect(result).to be_nil
302
308
  end
303
309
  end
304
310
  end
@@ -109,6 +109,15 @@ RSpec.describe LogStash::Outputs::Cassandra::SafeSubmitter do
109
109
  return future_double
110
110
  end
111
111
 
112
+ it 'does nothing in case it got a nil action' do
113
+ doubles = setup_session_double(default_options)
114
+ expect(doubles[:session_double]).to_not(receive(:prepare))
115
+ expect(doubles[:session_double]).to_not(receive(:execute_async))
116
+ sut_instance = sut.new(default_options)
117
+
118
+ expect { sut_instance.submit([nil]) }.to_not raise_error
119
+ end
120
+
112
121
  it 'prepares and executes the query' do
113
122
  doubles = setup_session_double(default_options)
114
123
  expect(doubles[:session_double]).to(receive(:prepare).with(expected_query_for_one_action)).and_return('eureka')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-cassandra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - PerimeterX
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-26 00:00:00.000000000 Z
11
+ date: 2016-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement