logstash-output-kinetica 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +2 -0
- data/CONTRIBUTORS +10 -0
- data/DEVELOPER.md +2 -0
- data/Gemfile +3 -0
- data/LICENSE +11 -0
- data/README.md +86 -0
- data/docs/index.asciidoc +372 -0
- data/lib/logstash/outputs/kinetica.rb +382 -0
- data/logstash-output-kinetica.gemspec +26 -0
- data/spec/outputs/kinetica_spec.rb +64 -0
- data/spec/supports/compressed_requests.rb +38 -0
- metadata +140 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e4b2de44e44655059a2becf687728ac628d96039c61bec8087ee962022b5e017
|
4
|
+
data.tar.gz: 7d54a709c25cff60974714f0ab717d4acfa505e4cbac95cc6d74fe33c89c2617
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c08cbf500bbcca13c0df19caeccd87e2abe1bfd4de9e4740495680ec6d0d0e41fea63ee16cb15b58ef2adab808f3501c1982d3bdb20cfb5e5fedab3743440fde
|
7
|
+
data.tar.gz: 59a06a990207debe3b763da7b5ee18fdad35415cf38a599e67b46ddd2561243d01c8b74aaaba1dacfe4174e2947ddaf8a507aab5dc0e6fe09069191fdefb1014
|
data/CHANGELOG.md
ADDED
data/CONTRIBUTORS
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
The following is a list of people who have contributed ideas, code, bug
|
2
|
+
reports, or in general have helped logstash along its way.
|
3
|
+
|
4
|
+
Contributors:
|
5
|
+
* -
|
6
|
+
|
7
|
+
Note: If you've sent us patches, bug reports, or otherwise contributed to
|
8
|
+
Logstash, and you aren't on the list above and want to be, please let us know
|
9
|
+
and we'll make sure you're here. Contributions from folks like you are what make
|
10
|
+
open source awesome.
|
data/DEVELOPER.md
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
2
|
+
you may not use this file except in compliance with the License.
|
3
|
+
You may obtain a copy of the License at
|
4
|
+
|
5
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
6
|
+
|
7
|
+
Unless required by applicable law or agreed to in writing, software
|
8
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
9
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
+
See the License for the specific language governing permissions and
|
11
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# Logstash Plugin
|
2
|
+
|
3
|
+
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
4
|
+
|
5
|
+
It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
|
6
|
+
|
7
|
+
## Documentation
|
8
|
+
|
9
|
+
Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elastic.co/guide/en/logstash/current/).
|
10
|
+
|
11
|
+
- For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
|
12
|
+
- For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
|
13
|
+
|
14
|
+
## Need Help?
|
15
|
+
|
16
|
+
Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
|
17
|
+
|
18
|
+
## Developing
|
19
|
+
|
20
|
+
### 1. Plugin Developement and Testing
|
21
|
+
|
22
|
+
#### Code
|
23
|
+
- To get started, you'll need JRuby with the Bundler gem installed.
|
24
|
+
|
25
|
+
- Create a new plugin or clone and existing from the GitHub [logstash-plugins](https://github.com/logstash-plugins) organization. We also provide [example plugins](https://github.com/logstash-plugins?query=example).
|
26
|
+
|
27
|
+
- Install dependencies
|
28
|
+
```sh
|
29
|
+
bundle install
|
30
|
+
```
|
31
|
+
|
32
|
+
#### Test
|
33
|
+
|
34
|
+
- Update your dependencies
|
35
|
+
|
36
|
+
```sh
|
37
|
+
bundle install
|
38
|
+
```
|
39
|
+
|
40
|
+
- Run tests
|
41
|
+
|
42
|
+
```sh
|
43
|
+
bundle exec rspec
|
44
|
+
```
|
45
|
+
|
46
|
+
### 2. Running your unpublished Plugin in Logstash
|
47
|
+
|
48
|
+
#### 2.1 Run in a local Logstash clone
|
49
|
+
|
50
|
+
- Edit Logstash `Gemfile` and add the local plugin path, for example:
|
51
|
+
```ruby
|
52
|
+
gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
|
53
|
+
```
|
54
|
+
- Install plugin
|
55
|
+
```sh
|
56
|
+
bin/logstash-plugin install --no-verify
|
57
|
+
```
|
58
|
+
- Run Logstash with your plugin
|
59
|
+
```sh
|
60
|
+
bin/logstash -e 'filter {awesome {}}'
|
61
|
+
```
|
62
|
+
At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
|
63
|
+
|
64
|
+
#### 2.2 Run in an installed Logstash
|
65
|
+
|
66
|
+
You can use the same **2.1** method to run your plugin in an installed Logstash by editing its `Gemfile` and pointing the `:path` to your local plugin development directory or you can build the gem and install it using:
|
67
|
+
|
68
|
+
- Build your plugin gem
|
69
|
+
```sh
|
70
|
+
gem build logstash-filter-awesome.gemspec
|
71
|
+
```
|
72
|
+
- Install the plugin from the Logstash home
|
73
|
+
```sh
|
74
|
+
bin/logstash-plugin install /your/local/plugin/logstash-filter-awesome.gem
|
75
|
+
```
|
76
|
+
- Start Logstash and proceed to test the plugin
|
77
|
+
|
78
|
+
## Contributing
|
79
|
+
|
80
|
+
All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
|
81
|
+
|
82
|
+
Programming is not a required skill. Whatever you've seen about open source and maintainers or community members saying "send patches or die" - you will not see that here.
|
83
|
+
|
84
|
+
It is more important to the community that you are able to contribute.
|
85
|
+
|
86
|
+
For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
|
data/docs/index.asciidoc
ADDED
@@ -0,0 +1,372 @@
|
|
1
|
+
:plugin: Kinetica
|
2
|
+
:type: output
|
3
|
+
:default_codec: plain
|
4
|
+
|
5
|
+
///////////////////////////////////////////
|
6
|
+
START - GENERATED VARIABLES, DO NOT EDIT!
|
7
|
+
///////////////////////////////////////////
|
8
|
+
:version: %VERSION%
|
9
|
+
:release_date: %RELEASE_DATE%
|
10
|
+
:changelog_url: %CHANGELOG_URL%
|
11
|
+
:include_path: ../../../../logstash/docs/include
|
12
|
+
///////////////////////////////////////////
|
13
|
+
END - GENERATED VARIABLES, DO NOT EDIT!
|
14
|
+
///////////////////////////////////////////
|
15
|
+
|
16
|
+
[id="plugins-{type}s-{plugin}"]
|
17
|
+
|
18
|
+
=== Kinetica output plugin
|
19
|
+
|
20
|
+
include::{include_path}/plugin_header.asciidoc[]
|
21
|
+
|
22
|
+
==== Description
|
23
|
+
|
24
|
+
This output lets you send events to a Kinetica database
|
25
|
+
|
26
|
+
This output will execute up to 'pool_max' requests in parallel for performance.
|
27
|
+
Consider this when tuning this plugin for performance.
|
28
|
+
|
29
|
+
Additionally, note that when parallel execution is used strict ordering of events is not
|
30
|
+
guaranteed!
|
31
|
+
|
32
|
+
[id="plugins-{type}s-{plugin}-options"]
|
33
|
+
==== Kinetica Output Configuration Options
|
34
|
+
|
35
|
+
This plugin supports the following configuration options plus the <<plugins-{type}s-{plugin}-common-options>> described later.
|
36
|
+
|
37
|
+
[cols="<,<,<",options="header",]
|
38
|
+
|=======================================================================
|
39
|
+
|Setting |Input type|Required
|
40
|
+
| <<plugins-{type}s-{plugin}-automatic_retries>> |<<number,number>>|No
|
41
|
+
| <<plugins-{type}s-{plugin}-cacert>> |a valid filesystem path|No
|
42
|
+
| <<plugins-{type}s-{plugin}-client_cert>> |a valid filesystem path|No
|
43
|
+
| <<plugins-{type}s-{plugin}-client_key>> |a valid filesystem path|No
|
44
|
+
| <<plugins-{type}s-{plugin}-connect_timeout>> |<<number,number>>|No
|
45
|
+
| <<plugins-{type}s-{plugin}-content_type>> |<<string,string>>|No
|
46
|
+
| <<plugins-{type}s-{plugin}-cookies>> |<<boolean,boolean>>|No
|
47
|
+
| <<plugins-{type}s-{plugin}-follow_redirects>> |<<boolean,boolean>>|No
|
48
|
+
| <<plugins-{type}s-{plugin}-headers>> |<<hash,hash>>|No
|
49
|
+
| <<plugins-{type}s-{plugin}-http_compression>> |<<boolean,boolean>>|No
|
50
|
+
| <<plugins-{type}s-{plugin}-ignorable_codes>> |<<number,number>>|No
|
51
|
+
| <<plugins-{type}s-{plugin}-keepalive>> |<<boolean,boolean>>|No
|
52
|
+
| <<plugins-{type}s-{plugin}-keystore>> |a valid filesystem path|No
|
53
|
+
| <<plugins-{type}s-{plugin}-keystore_password>> |<<password,password>>|No
|
54
|
+
| <<plugins-{type}s-{plugin}-keystore_type>> |<<string,string>>|No
|
55
|
+
| <<plugins-{type}s-{plugin}-kinetica_create_table_options>> |<<hash,hash>>|No
|
56
|
+
| <<plugins-{type}s-{plugin}-kinetica_options>> |<<hash,hash>>|No
|
57
|
+
| <<plugins-{type}s-{plugin}-pool_max>> |<<number,number>>|No
|
58
|
+
| <<plugins-{type}s-{plugin}-pool_max_per_route>> |<<number,number>>|No
|
59
|
+
| <<plugins-{type}s-{plugin}-proxy>> |<<,>>|No
|
60
|
+
| <<plugins-{type}s-{plugin}-request_timeout>> |<<number,number>>|No
|
61
|
+
| <<plugins-{type}s-{plugin}-retry_failed>> |<<boolean,boolean>>|No
|
62
|
+
| <<plugins-{type}s-{plugin}-retry_non_idempotent>> |<<boolean,boolean>>|No
|
63
|
+
| <<plugins-{type}s-{plugin}-retryable_codes>> |<<number,number>>|No
|
64
|
+
| <<plugins-{type}s-{plugin}-socket_timeout>> |<<number,number>>|No
|
65
|
+
| <<plugins-{type}s-{plugin}-table_name>> |<<string,string>>|Yes
|
66
|
+
| <<plugins-{type}s-{plugin}-truststore>> |a valid filesystem path|No
|
67
|
+
| <<plugins-{type}s-{plugin}-truststore_password>> |<<password,password>>|No
|
68
|
+
| <<plugins-{type}s-{plugin}-truststore_type>> |<<string,string>>|No
|
69
|
+
| <<plugins-{type}s-{plugin}-url>> |<<string,string>>|Yes
|
70
|
+
| <<plugins-{type}s-{plugin}-validate_after_inactivity>> |<<number,number>>|No
|
71
|
+
|=======================================================================
|
72
|
+
|
73
|
+
Also see <<plugins-{type}s-{plugin}-common-options>> for a list of options supported by all
|
74
|
+
output plugins.
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
[id="plugins-{type}s-{plugin}-automatic_retries"]
|
79
|
+
===== `automatic_retries`
|
80
|
+
|
81
|
+
* Value type is <<number,number>>
|
82
|
+
* Default value is `1`
|
83
|
+
|
84
|
+
How many times should the client retry a failing URL. We highly recommend NOT setting this value
|
85
|
+
to zero if keepalive is enabled. Some servers incorrectly end keepalives early requiring a retry!
|
86
|
+
Only IO related failures will be retried, such as connection timeouts and unreachable hosts.
|
87
|
+
Valid but non 2xx HTTP responses will always be retried, regardless of the value of this setting,
|
88
|
+
unless `retry_failed` is set.
|
89
|
+
Note: if `retry_non_idempotent` is NOT set only GET, HEAD, PUT, DELETE, OPTIONS, and TRACE requests will be retried.
|
90
|
+
|
91
|
+
[id="plugins-{type}s-{plugin}-cacert"]
|
92
|
+
===== `cacert`
|
93
|
+
|
94
|
+
* Value type is <<path,path>>
|
95
|
+
* There is no default value for this setting.
|
96
|
+
|
97
|
+
If you need to use a custom X.509 CA (.pem certs) specify the path to that here
|
98
|
+
|
99
|
+
[id="plugins-{type}s-{plugin}-client_cert"]
|
100
|
+
===== `client_cert`
|
101
|
+
|
102
|
+
* Value type is <<path,path>>
|
103
|
+
* There is no default value for this setting.
|
104
|
+
|
105
|
+
If you'd like to use a client certificate (note, most people don't want this) set the path to the x509 cert here
|
106
|
+
|
107
|
+
[id="plugins-{type}s-{plugin}-client_key"]
|
108
|
+
===== `client_key`
|
109
|
+
|
110
|
+
* Value type is <<path,path>>
|
111
|
+
* There is no default value for this setting.
|
112
|
+
|
113
|
+
If you're using a client certificate specify the path to the encryption key here
|
114
|
+
|
115
|
+
[id="plugins-{type}s-{plugin}-connect_timeout"]
|
116
|
+
===== `connect_timeout`
|
117
|
+
|
118
|
+
* Value type is <<number,number>>
|
119
|
+
* Default value is `10`
|
120
|
+
|
121
|
+
Timeout (in seconds) to wait for a connection to be established. Default is `10s`
|
122
|
+
|
123
|
+
[id="plugins-{type}s-{plugin}-content_type"]
|
124
|
+
===== `content_type`
|
125
|
+
|
126
|
+
* Value type is <<string,string>>
|
127
|
+
* Default value is `"application/json"`
|
128
|
+
|
129
|
+
Content type
|
130
|
+
|
131
|
+
[id="plugins-{type}s-{plugin}-cookies"]
|
132
|
+
===== `cookies`
|
133
|
+
|
134
|
+
* Value type is <<boolean,boolean>>
|
135
|
+
* Default value is `true`
|
136
|
+
|
137
|
+
Enable cookie support. With this enabled the client will persist cookies
|
138
|
+
across requests as a normal web browser would. Enabled by default
|
139
|
+
|
140
|
+
[id="plugins-{type}s-{plugin}-follow_redirects"]
|
141
|
+
===== `follow_redirects`
|
142
|
+
|
143
|
+
* Value type is <<boolean,boolean>>
|
144
|
+
* Default value is `true`
|
145
|
+
|
146
|
+
Should redirects be followed? Defaults to `true`
|
147
|
+
|
148
|
+
[id="plugins-{type}s-{plugin}-headers"]
|
149
|
+
===== `headers`
|
150
|
+
|
151
|
+
* Value type is <<hash,hash>>
|
152
|
+
* There is no default value for this setting.
|
153
|
+
|
154
|
+
Custom headers to use
|
155
|
+
format is `headers => ["X-My-Header", "%{host}"]`
|
156
|
+
|
157
|
+
[id="plugins-{type}s-{plugin}-http_compression"]
|
158
|
+
===== `http_compression`
|
159
|
+
|
160
|
+
* Value type is <<boolean,boolean>>
|
161
|
+
* Default value is `false`
|
162
|
+
|
163
|
+
Enable request compression support. With this enabled the plugin will compress
|
164
|
+
http requests using gzip.
|
165
|
+
|
166
|
+
[id="plugins-{type}s-{plugin}-http_method"]
|
167
|
+
===== `http_method`
|
168
|
+
|
169
|
+
* This is a required setting.
|
170
|
+
* Value can be any of: `put`, `post`, `patch`, `delete`, `get`, `head`
|
171
|
+
* There is no default value for this setting.
|
172
|
+
|
173
|
+
The HTTP Verb. One of "put", "post", "patch", "delete", "get", "head"
|
174
|
+
|
175
|
+
[id="plugins-{type}s-{plugin}-ignorable_codes"]
|
176
|
+
===== `ignorable_codes`
|
177
|
+
|
178
|
+
* Value type is <<number,number>>
|
179
|
+
* There is no default value for this setting.
|
180
|
+
|
181
|
+
If you would like to consider some non-2xx codes to be successes
|
182
|
+
enumerate them here. Responses returning these codes will be considered successes
|
183
|
+
|
184
|
+
[id="plugins-{type}s-{plugin}-keepalive"]
|
185
|
+
===== `keepalive`
|
186
|
+
|
187
|
+
* Value type is <<boolean,boolean>>
|
188
|
+
* Default value is `true`
|
189
|
+
|
190
|
+
Turn this on to enable HTTP keepalive support. We highly recommend setting `automatic_retries` to at least
|
191
|
+
one with this to fix interactions with broken keepalive implementations.
|
192
|
+
|
193
|
+
[id="plugins-{type}s-{plugin}-keystore"]
|
194
|
+
===== `keystore`
|
195
|
+
|
196
|
+
* Value type is <<path,path>>
|
197
|
+
* There is no default value for this setting.
|
198
|
+
|
199
|
+
If you need to use a custom keystore (`.jks`) specify that here. This does not work with .pem keys!
|
200
|
+
|
201
|
+
[id="plugins-{type}s-{plugin}-keystore_password"]
|
202
|
+
===== `keystore_password`
|
203
|
+
|
204
|
+
* Value type is <<password,password>>
|
205
|
+
* There is no default value for this setting.
|
206
|
+
|
207
|
+
Specify the keystore password here.
|
208
|
+
Note, most .jks files created with keytool require a password!
|
209
|
+
|
210
|
+
[id="plugins-{type}s-{plugin}-keystore_type"]
|
211
|
+
===== `keystore_type`
|
212
|
+
|
213
|
+
* Value type is <<string,string>>
|
214
|
+
* Default value is `"JKS"`
|
215
|
+
|
216
|
+
Specify the keystore type here. One of `JKS` or `PKCS12`. Default is `JKS`
|
217
|
+
|
218
|
+
[id="plugins-{type}s-{plugin}-kinetica_create_table_options"]
|
219
|
+
===== `kinetica_create_table_options`
|
220
|
+
|
221
|
+
* Value type is <<hash,hash>>
|
222
|
+
* There is no default value for this setting.
|
223
|
+
|
224
|
+
Optional parameters to be passed to Kinetica database as part of the request body. Options used when creating the target table. Includes type to use. The other options match those in /create/table. The default value is an empty map ( {} ). Refer to https://www.kinetica.com/docs/api/rest/insert_records_frompayload_rest.html for more information.
|
225
|
+
|
226
|
+
[id="plugins-{type}s-{plugin}-kinetica_options"]
|
227
|
+
===== `kinetica_options`
|
228
|
+
|
229
|
+
* Value type is <<hash,hash>>
|
230
|
+
* There is no default value for this setting.
|
231
|
+
|
232
|
+
Optional parameters to be passed to Kinetica database as part of the request body. The default value is an empty map ( {} ).
|
233
|
+
Refer to https://www.kinetica.com/docs/api/rest/insert_records_frompayload_rest.html for more info.
|
234
|
+
|
235
|
+
For example:
|
236
|
+
[source,ruby]
|
237
|
+
options => {"text_has_header"=>"false"
|
238
|
+
"error_handling"=>"abort"}
|
239
|
+
|
240
|
+
|
241
|
+
[id="plugins-{type}s-{plugin}-pool_max"]
|
242
|
+
===== `pool_max`
|
243
|
+
|
244
|
+
* Value type is <<number,number>>
|
245
|
+
* Default value is `50`
|
246
|
+
|
247
|
+
Max number of concurrent connections. Defaults to `50`
|
248
|
+
|
249
|
+
[id="plugins-{type}s-{plugin}-pool_max_per_route"]
|
250
|
+
===== `pool_max_per_route`
|
251
|
+
|
252
|
+
* Value type is <<number,number>>
|
253
|
+
* Default value is `25`
|
254
|
+
|
255
|
+
Max number of concurrent connections to a single host. Defaults to `25`
|
256
|
+
|
257
|
+
[id="plugins-{type}s-{plugin}-proxy"]
|
258
|
+
===== `proxy`
|
259
|
+
|
260
|
+
* Value type is <<string,string>>
|
261
|
+
* There is no default value for this setting.
|
262
|
+
|
263
|
+
If you'd like to use an HTTP proxy . This supports multiple configuration syntaxes:
|
264
|
+
|
265
|
+
1. Proxy host in form: `http://proxy.org:1234`
|
266
|
+
2. Proxy host in form: `{host => "proxy.org", port => 80, scheme => 'http', user => 'username@host', password => 'password'}`
|
267
|
+
3. Proxy host in form: `{url => 'http://proxy.org:1234', user => 'username@host', password => 'password'}`
|
268
|
+
|
269
|
+
[id="plugins-{type}s-{plugin}-request_timeout"]
|
270
|
+
===== `request_timeout`
|
271
|
+
|
272
|
+
* Value type is <<number,number>>
|
273
|
+
* Default value is `60`
|
274
|
+
|
275
|
+
This module makes it easy to add a very fully configured HTTP client to logstash
|
276
|
+
based on [Manticore](https://github.com/cheald/manticore).
|
277
|
+
For an example of its usage see https://github.com/logstash-plugins/logstash-input-http_poller
|
278
|
+
Timeout (in seconds) for the entire request
|
279
|
+
|
280
|
+
[id="plugins-{type}s-{plugin}-retry_failed"]
|
281
|
+
===== `retry_failed`
|
282
|
+
|
283
|
+
* Value type is <<boolean,boolean>>
|
284
|
+
* Default value is `true`
|
285
|
+
|
286
|
+
Set this to false if you don't want this output to retry failed requests
|
287
|
+
|
288
|
+
[id="plugins-{type}s-{plugin}-retry_non_idempotent"]
|
289
|
+
===== `retry_non_idempotent`
|
290
|
+
|
291
|
+
* Value type is <<boolean,boolean>>
|
292
|
+
* Default value is `false`
|
293
|
+
|
294
|
+
If `automatic_retries` is enabled this will cause non-idempotent HTTP verbs (such as POST) to be retried.
|
295
|
+
This only affects connectivity related errors (see related `automatic_retries` setting).
|
296
|
+
|
297
|
+
[id="plugins-{type}s-{plugin}-retryable_codes"]
|
298
|
+
===== `retryable_codes`
|
299
|
+
|
300
|
+
* Value type is <<number,number>>
|
301
|
+
* Default value is `[429, 500, 502, 503, 504]`
|
302
|
+
|
303
|
+
If encountered as response codes this plugin will retry these requests
|
304
|
+
|
305
|
+
[id="plugins-{type}s-{plugin}-socket_timeout"]
|
306
|
+
===== `socket_timeout`
|
307
|
+
|
308
|
+
* Value type is <<number,number>>
|
309
|
+
* Default value is `10`
|
310
|
+
|
311
|
+
Timeout (in seconds) to wait for data on the socket. Default is `10s`
|
312
|
+
|
313
|
+
[id="plugins-{type}s-{plugin}-table_name"]
|
314
|
+
===== `table_name`
|
315
|
+
|
316
|
+
* Value type is <<string,string>>
|
317
|
+
* There is no default value for this setting.
|
318
|
+
|
319
|
+
Name of the table into which the data will be inserted, in [schema_name.]table_name format, using standard name resolution rules. If the table does not exist, the table will be created using either an existing type_id or the type inferred from the payload, and the new table name will have to meet standard table naming criteria.
|
320
|
+
|
321
|
+
[id="plugins-{type}s-{plugin}-truststore"]
|
322
|
+
===== `truststore`
|
323
|
+
|
324
|
+
* Value type is <<path,path>>
|
325
|
+
* There is no default value for this setting.
|
326
|
+
|
327
|
+
If you need to use a custom truststore (`.jks`) specify that here. This does not work with .pem certs!
|
328
|
+
|
329
|
+
[id="plugins-{type}s-{plugin}-truststore_password"]
|
330
|
+
===== `truststore_password`
|
331
|
+
|
332
|
+
* Value type is <<password,password>>
|
333
|
+
* There is no default value for this setting.
|
334
|
+
|
335
|
+
Specify the truststore password here.
|
336
|
+
Note, most .jks files created with keytool require a password!
|
337
|
+
|
338
|
+
[id="plugins-{type}s-{plugin}-truststore_type"]
|
339
|
+
===== `truststore_type`
|
340
|
+
|
341
|
+
* Value type is <<string,string>>
|
342
|
+
* Default value is `"JKS"`
|
343
|
+
|
344
|
+
Specify the truststore type here. One of `JKS` or `PKCS12`. Default is `JKS`
|
345
|
+
|
346
|
+
[id="plugins-{type}s-{plugin}-url"]
|
347
|
+
===== `url`
|
348
|
+
|
349
|
+
* This is a required setting.
|
350
|
+
* Value type is <<string,string>>
|
351
|
+
* There is no default value for this setting.
|
352
|
+
|
353
|
+
URL to use
|
354
|
+
|
355
|
+
[id="plugins-{type}s-{plugin}-validate_after_inactivity"]
|
356
|
+
===== `validate_after_inactivity`
|
357
|
+
|
358
|
+
* Value type is <<number,number>>
|
359
|
+
* Default value is `200`
|
360
|
+
|
361
|
+
How long to wait before checking if the connection is stale before executing a request on a connection using keepalive.
|
362
|
+
You may want to set this lower, possibly to 0 if you get connection errors regularly
|
363
|
+
Quoting the Apache commons docs (this client is based Apache Commmons):
|
364
|
+
'Defines period of inactivity in milliseconds after which persistent connections must be re-validated prior to being leased to the consumer. Non-positive value passed to this method disables connection validation. This check helps detect connections that have become stale (half-closed) while kept inactive in the pool.'
|
365
|
+
See https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/conn/PoolingHttpClientConnectionManager.html#setValidateAfterInactivity(int)[these docs for more info]
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
[id="plugins-{type}s-{plugin}-common-options"]
|
370
|
+
include::{include_path}/{type}.asciidoc[]
|
371
|
+
|
372
|
+
:default_codec!:
|
@@ -0,0 +1,382 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "logstash/outputs/base"
|
3
|
+
require "logstash/namespace"
|
4
|
+
require "logstash/json"
|
5
|
+
require "uri"
|
6
|
+
require "logstash/plugin_mixins/http_client"
|
7
|
+
require "zlib"
|
8
|
+
require "json"
|
9
|
+
|
10
|
+
class LogStash::Outputs::Kinetica < LogStash::Outputs::Base
|
11
|
+
include LogStash::PluginMixins::HttpClient
|
12
|
+
|
13
|
+
concurrency :shared
|
14
|
+
|
15
|
+
attr_accessor :is_batch
|
16
|
+
|
17
|
+
VALID_METHODS = ["post"]
|
18
|
+
|
19
|
+
RETRYABLE_MANTICORE_EXCEPTIONS = [
|
20
|
+
::Manticore::Timeout,
|
21
|
+
::Manticore::SocketException,
|
22
|
+
::Manticore::ClientProtocolException,
|
23
|
+
::Manticore::ResolutionFailure,
|
24
|
+
::Manticore::SocketTimeout
|
25
|
+
]
|
26
|
+
|
27
|
+
# This output lets you send events to a Kinetica database
|
28
|
+
#
|
29
|
+
# This output will execute up to 'pool_max' requests in parallel for performance.
|
30
|
+
# Consider this when tuning this plugin for performance.
|
31
|
+
#
|
32
|
+
# Additionally, note that when parallel execution is used strict ordering of events is not
|
33
|
+
# guaranteed!
|
34
|
+
|
35
|
+
config_name "kinetica"
|
36
|
+
|
37
|
+
# URL to use
|
38
|
+
config :url, :validate => :string, :required => :true
|
39
|
+
|
40
|
+
# Name of the table into which the data will be inserted, in [schema_name.]table_name format, using standard name resolution rules.
|
41
|
+
# If the table does not exist, the table will be created using either an existing type_id or the type inferred from the payload,
|
42
|
+
# and the new table name will have to meet standard table naming criteria.
|
43
|
+
config :table_name, :validate => :string, :required => :true
|
44
|
+
|
45
|
+
# Options used when creating the target table. Includes type to use. The other options match those in /create/table. The default value is an empty map ( {} ).
|
46
|
+
# Refer to https://www.kinetica.com/docs/api/rest/insert_records_frompayload_rest.html for more info
|
47
|
+
config :create_table_options, :validate => :hash, :default => {}
|
48
|
+
|
49
|
+
# Optional parameters. The default value is an empty map ( {} ).
|
50
|
+
# Refer to https://www.kinetica.com/docs/api/rest/insert_records_frompayload_rest.html for more info
|
51
|
+
# Example: {"text_has_header"=>"false", "error_handling"=>"abort"}
|
52
|
+
config :options, :validate => :hash, :default => {}
|
53
|
+
|
54
|
+
# Custom headers to use
|
55
|
+
# format is `headers => ["X-My-Header", "%{host}"]`
|
56
|
+
config :headers, :validate => :hash, :default => {}
|
57
|
+
|
58
|
+
# Content type
|
59
|
+
#
|
60
|
+
# If not specified, this defaults to the following:
|
61
|
+
#
|
62
|
+
# * if format is "csv", "application/json"
|
63
|
+
config :content_type, :validate => :string, :default => "application/json"
|
64
|
+
|
65
|
+
# Set this to false if you don't want this output to retry failed requests
|
66
|
+
config :retry_failed, :validate => :boolean, :default => true
|
67
|
+
|
68
|
+
# If encountered as response codes this plugin will retry these requests
|
69
|
+
config :retryable_codes, :validate => :number, :list => true, :default => [429, 500, 502, 503, 504]
|
70
|
+
|
71
|
+
# If you would like to consider some non-2xx codes to be successes
|
72
|
+
# enumerate them here. Responses returning these codes will be considered successes
|
73
|
+
config :ignorable_codes, :validate => :number, :list => true
|
74
|
+
|
75
|
+
# Set the format of the http body.
|
76
|
+
#
|
77
|
+
# If form, then the body will be the mapping (or whole event) converted
|
78
|
+
# into a query parameter string, e.g. `foo=bar&baz=fizz...`
|
79
|
+
#
|
80
|
+
# If message, then the body will be the result of formatting the event according to message
|
81
|
+
#
|
82
|
+
# Otherwise, the event is sent as json.
|
83
|
+
config :format, :validate => ["csv"], :default => "csv"
|
84
|
+
|
85
|
+
# Set this to true if you want to enable gzip compression for your http requests
|
86
|
+
config :http_compression, :validate => :boolean, :default => false
|
87
|
+
|
88
|
+
def register
|
89
|
+
#@http_method = @http_method.to_sym
|
90
|
+
|
91
|
+
# We count outstanding requests with this queue
|
92
|
+
# This queue tracks the requests to create backpressure
|
93
|
+
# When this queue is empty no new requests may be sent,
|
94
|
+
# tokens must be added back by the client on success
|
95
|
+
@request_tokens = SizedQueue.new(@pool_max)
|
96
|
+
@pool_max.times {|t| @request_tokens << true }
|
97
|
+
|
98
|
+
@requests = Array.new
|
99
|
+
|
100
|
+
if @content_type.nil?
|
101
|
+
case @format
|
102
|
+
#when "form" ; @content_type = "application/x-www-form-urlencoded"
|
103
|
+
#when "json" ; @content_type = "application/json"
|
104
|
+
#when "json_batch" ; @content_type = "application/json"
|
105
|
+
when "csv" ; @content_type = "application/json"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
@is_batch = @format == "json_batch"
|
110
|
+
|
111
|
+
@headers["Content-Type"] = @content_type
|
112
|
+
|
113
|
+
# Run named Timer as daemon thread
|
114
|
+
@timer = java.util.Timer.new("HTTP Output #{self.params['id']}", true)
|
115
|
+
|
116
|
+
@text_delimiter = options["text_delimiter"].nil? ? "," : options["text_delimiter"]
|
117
|
+
|
118
|
+
@text_escape_character = options["text_escape_character"].nil? ? "\\" : options["text_escape_character"]
|
119
|
+
end # def register
|
120
|
+
|
121
|
+
def multi_receive(events)
|
122
|
+
return if events.empty?
|
123
|
+
send_events(events)
|
124
|
+
end
|
125
|
+
|
126
|
+
class RetryTimerTask < java.util.TimerTask
|
127
|
+
def initialize(pending, event, attempt)
|
128
|
+
@pending = pending
|
129
|
+
@event = event
|
130
|
+
@attempt = attempt
|
131
|
+
super()
|
132
|
+
end
|
133
|
+
|
134
|
+
def run
|
135
|
+
@pending << [@event, @attempt]
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def log_retryable_response(response)
|
140
|
+
if (response.code == 429)
|
141
|
+
@logger.debug? && @logger.debug("Encountered a 429 response, will retry. This is not serious, just flow control via HTTP")
|
142
|
+
else
|
143
|
+
@logger.warn("Encountered a retryable HTTP request in HTTP output, will retry", :code => response.code, :body => response.body)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
def log_error_response(response, url, event)
|
148
|
+
body_json=JSON.parse(response.body)
|
149
|
+
response_message = body_json["message"]
|
150
|
+
log_failure(
|
151
|
+
"Encountered an error:",
|
152
|
+
:response_code => response.code,
|
153
|
+
:response_message => response_message,
|
154
|
+
:url => url,
|
155
|
+
:event => event
|
156
|
+
)
|
157
|
+
end
|
158
|
+
|
159
|
+
def send_events(events)
|
160
|
+
successes = java.util.concurrent.atomic.AtomicInteger.new(0)
|
161
|
+
failures = java.util.concurrent.atomic.AtomicInteger.new(0)
|
162
|
+
retries = java.util.concurrent.atomic.AtomicInteger.new(0)
|
163
|
+
event_count = @is_batch ? 1 : events.size
|
164
|
+
|
165
|
+
pending = Queue.new
|
166
|
+
if @is_batch
|
167
|
+
pending << [events, 0]
|
168
|
+
else
|
169
|
+
events.each {|e| pending << [e, 0]}
|
170
|
+
end
|
171
|
+
|
172
|
+
while popped = pending.pop
|
173
|
+
break if popped == :done
|
174
|
+
|
175
|
+
event, attempt = popped
|
176
|
+
|
177
|
+
action, event, attempt = send_event(event, attempt)
|
178
|
+
begin
|
179
|
+
action = :failure if action == :retry && !@retry_failed
|
180
|
+
|
181
|
+
case action
|
182
|
+
when :success
|
183
|
+
successes.incrementAndGet
|
184
|
+
when :retry
|
185
|
+
retries.incrementAndGet
|
186
|
+
next_attempt = attempt+1
|
187
|
+
sleep_for = sleep_for_attempt(next_attempt)
|
188
|
+
@logger.info("Retrying http request, will sleep for #{sleep_for} seconds")
|
189
|
+
timer_task = RetryTimerTask.new(pending, event, next_attempt)
|
190
|
+
@timer.schedule(timer_task, sleep_for*1000)
|
191
|
+
when :failure
|
192
|
+
failures.incrementAndGet
|
193
|
+
else
|
194
|
+
raise "Unknown action #{action}"
|
195
|
+
end
|
196
|
+
|
197
|
+
if action == :success || action == :failure
|
198
|
+
if successes.get+failures.get == event_count
|
199
|
+
pending << :done
|
200
|
+
end
|
201
|
+
end
|
202
|
+
rescue => e
|
203
|
+
# This should never happen unless there's a flat out bug in the code
|
204
|
+
@logger.error("Error sending HTTP Request",
|
205
|
+
:class => e.class.name,
|
206
|
+
:message => e.message,
|
207
|
+
:backtrace => e.backtrace)
|
208
|
+
failures.incrementAndGet
|
209
|
+
raise e
|
210
|
+
end
|
211
|
+
end
|
212
|
+
rescue => e
|
213
|
+
@logger.error("Error in http output loop",
|
214
|
+
:class => e.class.name,
|
215
|
+
:message => e.message,
|
216
|
+
:backtrace => e.backtrace)
|
217
|
+
raise e
|
218
|
+
end
|
219
|
+
|
220
|
+
def sleep_for_attempt(attempt)
|
221
|
+
sleep_for = attempt**2
|
222
|
+
sleep_for = sleep_for <= 60 ? sleep_for : 60
|
223
|
+
(sleep_for/2) + (rand(0..sleep_for)/2)
|
224
|
+
end
|
225
|
+
|
226
|
+
def send_event(event, attempt)
|
227
|
+
body = event_body(event)
|
228
|
+
|
229
|
+
# Send the request
|
230
|
+
url = @is_batch ? @url : event.sprintf(@url)
|
231
|
+
headers = @is_batch ? @headers : event_headers(event)
|
232
|
+
|
233
|
+
# Compress the body and add appropriate header
|
234
|
+
if @http_compression == true
|
235
|
+
headers["Content-Encoding"] = "gzip"
|
236
|
+
body = gzip(body)
|
237
|
+
end
|
238
|
+
|
239
|
+
# Create an async request
|
240
|
+
puts(@logger.class)
|
241
|
+
response = client.send(:post, url, :body => body, :headers => headers).call
|
242
|
+
if !response_success?(response)
|
243
|
+
if retryable_response?(response)
|
244
|
+
log_retryable_response(response)
|
245
|
+
return :retry, event, attempt
|
246
|
+
else
|
247
|
+
log_error_response(response, url, event)
|
248
|
+
return :failure, event, attempt
|
249
|
+
end
|
250
|
+
else
|
251
|
+
return :success, event, attempt
|
252
|
+
end
|
253
|
+
|
254
|
+
rescue => exception
|
255
|
+
will_retry = retryable_exception?(exception)
|
256
|
+
log_failure("Could not fetch URL",
|
257
|
+
:url => url,
|
258
|
+
:body => body,
|
259
|
+
:headers => headers,
|
260
|
+
:message => exception.message,
|
261
|
+
:class => exception.class.name,
|
262
|
+
:backtrace => exception.backtrace,
|
263
|
+
:will_retry => will_retry
|
264
|
+
)
|
265
|
+
|
266
|
+
if will_retry
|
267
|
+
return :retry, event, attempt
|
268
|
+
else
|
269
|
+
return :failure, event, attempt
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
def close
|
274
|
+
@timer.cancel
|
275
|
+
client.close
|
276
|
+
end
|
277
|
+
|
278
|
+
private
|
279
|
+
|
280
|
+
def response_success?(response)
|
281
|
+
code = response.code
|
282
|
+
message = response.message
|
283
|
+
body = response.body
|
284
|
+
body_json=JSON.parse(body)
|
285
|
+
unless body_json["status"].nil?
|
286
|
+
@logger.info("status: #{body_json["status"]}")
|
287
|
+
if body_json["status"] == "ERROR"
|
288
|
+
@logger.error("message: #{body_json["message"]}")
|
289
|
+
return false
|
290
|
+
end
|
291
|
+
end
|
292
|
+
return true if @ignorable_codes && @ignorable_codes.include?(code)
|
293
|
+
return code >= 200 && code <= 299
|
294
|
+
end
|
295
|
+
|
296
|
+
def retryable_response?(response)
|
297
|
+
@retryable_codes && @retryable_codes.include?(response.code)
|
298
|
+
end
|
299
|
+
|
300
|
+
def retryable_exception?(exception)
|
301
|
+
RETRYABLE_MANTICORE_EXCEPTIONS.any? {|me| exception.is_a?(me) }
|
302
|
+
end
|
303
|
+
|
304
|
+
# This is split into a separate method mostly to help testing
|
305
|
+
def log_failure(message, opts)
|
306
|
+
@logger.error("[HTTP Output Failure] #{message}", opts)
|
307
|
+
end
|
308
|
+
|
309
|
+
# Format the HTTP body
|
310
|
+
def event_body(event)
|
311
|
+
@logger.info("event: #{event.to_s}")
|
312
|
+
j=event.to_hash
|
313
|
+
@logger.info("event: #{j}")
|
314
|
+
first=true
|
315
|
+
data=""
|
316
|
+
j.keys.sort.each {
|
317
|
+
|k|
|
318
|
+
val=j[k].to_s.gsub("\"", "\\\"").gsub("\\","\\\\\\")
|
319
|
+
if first
|
320
|
+
data=val
|
321
|
+
first = false
|
322
|
+
else
|
323
|
+
data="#{data}#{@text_delimiter}#{val}"
|
324
|
+
end
|
325
|
+
}
|
326
|
+
body='{
|
327
|
+
"table_name": "'+@table_name+'",
|
328
|
+
"data_text": "'+data+'",
|
329
|
+
"create_table_options": '+create_table_options.to_json+',
|
330
|
+
"options": '+options.to_json+'
|
331
|
+
}'
|
332
|
+
@logger.info("body: #{body}")
|
333
|
+
body
|
334
|
+
end
|
335
|
+
|
336
|
+
# gzip data
|
337
|
+
def gzip(data)
|
338
|
+
gz = StringIO.new
|
339
|
+
gz.set_encoding("BINARY")
|
340
|
+
z = Zlib::GzipWriter.new(gz)
|
341
|
+
z.write(data)
|
342
|
+
z.close
|
343
|
+
gz.string
|
344
|
+
end
|
345
|
+
|
346
|
+
# def convert_mapping(mapping, event)
|
347
|
+
# if mapping.is_a?(Hash)
|
348
|
+
# mapping.reduce({}) do |acc, kv|
|
349
|
+
# k, v = kv
|
350
|
+
# acc[k] = convert_mapping(v, event)
|
351
|
+
# acc
|
352
|
+
# end
|
353
|
+
# elsif mapping.is_a?(Array)
|
354
|
+
# mapping.map { |elem| convert_mapping(elem, event) }
|
355
|
+
# else
|
356
|
+
# event.sprintf(mapping)
|
357
|
+
# end
|
358
|
+
# end
|
359
|
+
#
|
360
|
+
# def map_event(event)
|
361
|
+
# if @mapping
|
362
|
+
# convert_mapping(@mapping, event)
|
363
|
+
# else
|
364
|
+
# event.to_hash
|
365
|
+
# end
|
366
|
+
# end
|
367
|
+
|
368
|
+
def event_headers(event)
|
369
|
+
custom_headers(event) || {}
|
370
|
+
end
|
371
|
+
|
372
|
+
def custom_headers(event)
|
373
|
+
return nil unless @headers
|
374
|
+
|
375
|
+
@headers.reduce({}) do |acc,kv|
|
376
|
+
k,v = kv
|
377
|
+
acc[k] = event.sprintf(v)
|
378
|
+
acc
|
379
|
+
end
|
380
|
+
end
|
381
|
+
|
382
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'logstash-output-kinetica'
|
3
|
+
s.version = '0.1.2'
|
4
|
+
s.licenses = ['Apache-2.0']
|
5
|
+
s.summary = 'This is a logstash output plugin that lets you send events to a Kinetica database.'
|
6
|
+
s.homepage = 'https://github.com/durika/logstash-output-kinetica'
|
7
|
+
s.authors = ['Juraj Kristofik']
|
8
|
+
s.email = 'jkristofik@kinetica.com'
|
9
|
+
s.require_paths = ['lib']
|
10
|
+
|
11
|
+
# Files
|
12
|
+
s.files = Dir["lib/**/*","spec/**/*","*.gemspec","*.md","CONTRIBUTORS","Gemfile","LICENSE","NOTICE.TXT", "vendor/jar-dependencies/**/*.jar", "vendor/jar-dependencies/**/*.rb", "VERSION", "docs/**/*"]
|
13
|
+
# Tests
|
14
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
15
|
+
|
16
|
+
# Special flag to let us know this is actually a logstash plugin
|
17
|
+
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }
|
18
|
+
|
19
|
+
# Gem dependencies
|
20
|
+
s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
|
21
|
+
s.add_runtime_dependency "logstash-mixin-http_client", ">= 6.0.0", "< 8.0.0"
|
22
|
+
|
23
|
+
s.add_development_dependency 'logstash-devutils'
|
24
|
+
s.add_development_dependency 'sinatra'
|
25
|
+
s.add_development_dependency 'webrick'
|
26
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require "logstash/devutils/rspec/spec_helper"
|
2
|
+
require "logstash/outputs/kinetica"
|
3
|
+
require "logstash/codecs/plain"
|
4
|
+
require "logstash/logging"
|
5
|
+
|
6
|
+
class LogStash::Outputs::Kinetica
|
7
|
+
attr_writer :agent
|
8
|
+
attr_reader :request_tokens
|
9
|
+
LogStash::Logging::Logger.reconfigure("./log4j2.properties")
|
10
|
+
end
|
11
|
+
|
12
|
+
describe LogStash::Outputs::Kinetica do
|
13
|
+
let(:event) {
|
14
|
+
LogStash::Event.new({"message" => "1\\23"})
|
15
|
+
}
|
16
|
+
let(:url) { "http://192.168.56.101:9191/insert/records/frompayload" }
|
17
|
+
let(:method) { :post }
|
18
|
+
|
19
|
+
shared_examples("basic tests") do
|
20
|
+
let(:basic_tests_config) { {"url" => url, "pool_max" => 1, "user" => "user", "password" => "Password_1",\
|
21
|
+
"table_name" => "jkr_test", "options" => {"text_has_header"=>"false", "error_handling"=>"abort"} } }
|
22
|
+
subject { LogStash::Outputs::Kinetica.new(basic_tests_config) }
|
23
|
+
|
24
|
+
let(:expected_method) { method.clone.to_sym }
|
25
|
+
let(:client) { subject.client }
|
26
|
+
|
27
|
+
before do
|
28
|
+
subject.register
|
29
|
+
allow(client).to receive(:send).
|
30
|
+
with(expected_method, url, anything).
|
31
|
+
and_call_original
|
32
|
+
allow(subject).to receive(:log_failure).with(any_args)
|
33
|
+
allow(subject).to receive(:log_retryable_response).with(any_args)
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
context "performing a request" do
|
38
|
+
describe "invoking the request" do
|
39
|
+
before do
|
40
|
+
subject.multi_receive([event])
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should execute the request" do
|
44
|
+
expect(client).to have_received(:send).
|
45
|
+
with(expected_method, url, anything)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context "with passing requests" do
|
50
|
+
before do
|
51
|
+
subject.multi_receive([event])
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should not log a failure" do
|
55
|
+
expect(subject).not_to have_received(:log_failure).with(any_args)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context "basic test" do
|
62
|
+
include_examples("basic tests")
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# based on relistan's rack handler
|
4
|
+
# out of the box rack only gives use the rack deflater handler to return compressed
|
5
|
+
# response, this gist offer the inverse and should work on all rack based app like sinatra or rails.
|
6
|
+
#
|
7
|
+
# original source: https://gist.github.com/relistan/2109707
|
8
|
+
require "zlib"
|
9
|
+
|
10
|
+
class CompressedRequests
|
11
|
+
def initialize(app)
|
12
|
+
@app = app
|
13
|
+
end
|
14
|
+
|
15
|
+
def encoding_handled?(env)
|
16
|
+
['gzip', 'deflate'].include? env['HTTP_CONTENT_ENCODING']
|
17
|
+
end
|
18
|
+
|
19
|
+
def call(env)
|
20
|
+
if encoding_handled?(env)
|
21
|
+
extracted = decode(env['rack.input'], env['HTTP_CONTENT_ENCODING'])
|
22
|
+
|
23
|
+
env.delete('HTTP_CONTENT_ENCODING')
|
24
|
+
env['CONTENT_LENGTH'] = extracted.bytesize
|
25
|
+
env['rack.input'] = StringIO.new(extracted)
|
26
|
+
end
|
27
|
+
|
28
|
+
status, headers, response = @app.call(env)
|
29
|
+
return [status, headers, response]
|
30
|
+
end
|
31
|
+
|
32
|
+
def decode(input, content_encoding)
|
33
|
+
case content_encoding
|
34
|
+
when 'gzip' then Zlib::GzipReader.new(input).read
|
35
|
+
when 'deflate' then Zlib::Inflate.inflate(input.read)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logstash-output-kinetica
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Juraj Kristofik
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-03-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '1.60'
|
19
|
+
- - "<="
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '2.99'
|
22
|
+
name: logstash-core-plugin-api
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.60'
|
30
|
+
- - "<="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.99'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 6.0.0
|
39
|
+
- - "<"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 8.0.0
|
42
|
+
name: logstash-mixin-http_client
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 6.0.0
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 8.0.0
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
requirement: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
name: logstash-devutils
|
60
|
+
type: :development
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
requirement: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
name: sinatra
|
74
|
+
type: :development
|
75
|
+
prerelease: false
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
requirement: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
name: webrick
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
description:
|
96
|
+
email: jkristofik@kinetica.com
|
97
|
+
executables: []
|
98
|
+
extensions: []
|
99
|
+
extra_rdoc_files: []
|
100
|
+
files:
|
101
|
+
- CHANGELOG.md
|
102
|
+
- CONTRIBUTORS
|
103
|
+
- DEVELOPER.md
|
104
|
+
- Gemfile
|
105
|
+
- LICENSE
|
106
|
+
- README.md
|
107
|
+
- docs/index.asciidoc
|
108
|
+
- lib/logstash/outputs/kinetica.rb
|
109
|
+
- logstash-output-kinetica.gemspec
|
110
|
+
- spec/outputs/kinetica_spec.rb
|
111
|
+
- spec/supports/compressed_requests.rb
|
112
|
+
homepage: https://github.com/durika/logstash-output-kinetica
|
113
|
+
licenses:
|
114
|
+
- Apache-2.0
|
115
|
+
metadata:
|
116
|
+
logstash_plugin: 'true'
|
117
|
+
logstash_group: output
|
118
|
+
post_install_message:
|
119
|
+
rdoc_options: []
|
120
|
+
require_paths:
|
121
|
+
- lib
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
requirements: []
|
133
|
+
rubygems_version: 3.0.9
|
134
|
+
signing_key:
|
135
|
+
specification_version: 4
|
136
|
+
summary: This is a logstash output plugin that lets you send events to a Kinetica
|
137
|
+
database.
|
138
|
+
test_files:
|
139
|
+
- spec/outputs/kinetica_spec.rb
|
140
|
+
- spec/supports/compressed_requests.rb
|