logstash-output-amazon_es 7.0.1-java → 8.0.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -0
- data/NOTICE.TXT +10 -10
- data/README.md +144 -34
- data/lib/logstash/outputs/amazon_es/common.rb +11 -3
- data/lib/logstash/outputs/amazon_es/common_configs.rb +4 -0
- data/lib/logstash/outputs/amazon_es/http_client/manticore_adapter.rb +26 -19
- data/lib/logstash/outputs/amazon_es/http_client/pool.rb +28 -17
- data/lib/logstash/outputs/amazon_es/http_client.rb +9 -2
- data/lib/logstash/outputs/amazon_es/http_client_builder.rb +7 -1
- data/lib/logstash/outputs/amazon_es/template_manager.rb +4 -0
- data/lib/logstash/outputs/amazon_es.rb +14 -1
- data/logstash-output-amazon_es.gemspec +6 -2
- data/spec/es_spec_helper.rb +4 -0
- data/spec/unit/http_client_builder_spec.rb +4 -0
- data/spec/unit/outputs/elasticsearch/http_client/manticore_adapter_spec.rb +4 -0
- data/spec/unit/outputs/elasticsearch/http_client/pool_spec.rb +4 -0
- data/spec/unit/outputs/elasticsearch/http_client_spec.rb +4 -0
- data/spec/unit/outputs/elasticsearch/template_manager_spec.rb +4 -0
- data/spec/unit/outputs/elasticsearch_spec.rb +4 -0
- data/spec/unit/outputs/error_whitelist_spec.rb +4 -0
- metadata +19 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2ee2078a352ec70e02b1a7ea155920fa46321a5338988e51a16fb252f4fc3e5
|
4
|
+
data.tar.gz: 9ddbcfb3abedb40c41c27784c3c76ed8358ddda3ed57a15be569fec0a5ecbd03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf71c118ab4fbb00a2b317f380fb5e0e05fd8db866f3f01b63ec3cb1ad066dae2f78f77a9e9c4980c5c824879efdff711b0bd94e130ea32e81516a47fb3f8d36
|
7
|
+
data.tar.gz: f5543338eb6057ed5c29653fedd8e2710a14b610617b2e7ce94f2ca91d4770aadcaece33ffcc7152b8f3bb103eef26ff7f6eb5c3f3d65e9c1705670486e41043
|
data/Gemfile
CHANGED
data/NOTICE.TXT
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
Logstash-output-amazon_es Plugin
|
2
|
-
Copyright
|
2
|
+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
3
3
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
you may not use this file except in compliance with the License.
|
6
|
-
You may obtain a copy of the License at
|
7
4
|
|
8
|
-
|
5
|
+
This product includes software from the Apache-2.0 licensed Elasticsearch project.
|
9
6
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
7
|
+
It requires the following notice:
|
8
|
+
|
9
|
+
Elasticsearch
|
10
|
+
Copyright 2012-2015 Elasticsearch
|
11
|
+
Copyright 2020 Elastic and contributors
|
12
|
+
|
13
|
+
This product includes software developed by The Apache Software
|
14
|
+
Foundation (http://www.apache.org/).
|
data/README.md
CHANGED
@@ -1,6 +1,71 @@
|
|
1
|
-
# Logstash Plugin
|
1
|
+
# Logstash Output Plugin
|
2
2
|
|
3
|
-
|
3
|
+
|
4
|
+
This plugin is now in maintenance mode. We will supply bug fixes and security patches for v7.2.X, older versions are no longer supported. This change is because the OpenSearch Project created a new Logstash output plugin
|
5
|
+
[logstash-output-opensearch](https://github.com/opensearch-project/logstash-output-opensearch) which ships events from
|
6
|
+
Logstash to OpenSearch 1.x and Elasticsearch 7.x clusters, and also supports SigV4 signing. Having similar functionality
|
7
|
+
plugins can be redundant, so we plan to eventually replace this logstash-output-amazon_es plugin with the logstash-output-opensearch
|
8
|
+
plugin.
|
9
|
+
|
10
|
+
To help you migrate to [logstash-output-opensearch](https://github.com/opensearch-project/logstash-output-opensearch) plugin, please
|
11
|
+
find below a brief migration guide.
|
12
|
+
|
13
|
+
## Migrating to logstash-output-opensearch plugin
|
14
|
+
|
15
|
+
|
16
|
+
This guide provides instructions for existing users of logstash-output-amazon_es plugin to migrate to
|
17
|
+
logstash-output-opensearch plugin.
|
18
|
+
|
19
|
+
### Configuration Changes
|
20
|
+
* The plugin name will change from `amazon_es` to `opensearch`.
|
21
|
+
* If using HTTPS this must be explicitly configured because `opensearch` plugin does not default to it like `amazon_es` does:
|
22
|
+
* The protocol must be included in `hosts` as `https` (or option `ssl` added with value `true`)
|
23
|
+
* `port` must explicitly specified as `443`
|
24
|
+
* A new parameter `auth_type` will be added to the Config to support SigV4 signing.
|
25
|
+
* The `region` parameter will move under `auth_type`.
|
26
|
+
* Credential parameters `aws_access_key_id` and `aws_secret_access_key` will move under `auth_type`.
|
27
|
+
* The `type` value for `auth_type` for SigV4 signing will be set to `aws_iam`.
|
28
|
+
|
29
|
+
For the Logstash configuration provided in [Configuration for Amazon Elasticsearch Service Output Plugin
|
30
|
+
](#configuration-for-amazon-elasticsearch-service-output-plugin), here's a mapped example configuration for
|
31
|
+
logstash-output-opensearch plugin:
|
32
|
+
|
33
|
+
```
|
34
|
+
output {
|
35
|
+
opensearch {
|
36
|
+
hosts => ["https://hostname:port"]
|
37
|
+
auth_type => {
|
38
|
+
type => 'aws_iam'
|
39
|
+
aws_access_key_id => 'ACCESS_KEY'
|
40
|
+
aws_secret_access_key => 'SECRET_KEY'
|
41
|
+
region => 'us-west-2'
|
42
|
+
}
|
43
|
+
index => "logstash-logs-%{+YYYY.MM.dd}"
|
44
|
+
}
|
45
|
+
}
|
46
|
+
```
|
47
|
+
|
48
|
+
### Installation of logstash-output-opensearch plugin
|
49
|
+
This [Installation Guide](https://opensearch.org/docs/latest/clients/logstash/index/) has instructions on installing the
|
50
|
+
logstash-output-opensearch plugin in two ways: Linux (ARM64/X64) OR Docker (ARM64/X64).
|
51
|
+
|
52
|
+
To install the latest version of logstash-output-opensearch, use the normal Logstash plugin installation command:
|
53
|
+
```shell
|
54
|
+
bin/logstash-plugin install logstash-output-opensearch
|
55
|
+
```
|
56
|
+
|
57
|
+
# Using the logstash-output-amazon_es plugin
|
58
|
+
|
59
|
+
|
60
|
+
The remainder of this document is for using or developing the logstash-output-amazon_es plugin.
|
61
|
+
|
62
|
+
|
63
|
+
## Overview
|
64
|
+
|
65
|
+
This is a plugin for [Logstash](https://github.com/elastic/logstash) which outputs
|
66
|
+
to [Amazon OpenSearch Service](https://aws.amazon.com/opensearch-service/)
|
67
|
+
(successor to Amazon Elasticsearch Service) using
|
68
|
+
[SigV4 signing](https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html).
|
4
69
|
|
5
70
|
## License
|
6
71
|
|
@@ -8,14 +73,52 @@ This library is licensed under Apache License 2.0.
|
|
8
73
|
|
9
74
|
## Compatibility
|
10
75
|
|
11
|
-
The following table shows the versions of logstash and logstash-output-amazon_es
|
76
|
+
The following table shows the versions of logstash and logstash-output-amazon_es plugin was built with.
|
12
77
|
|
13
|
-
|
|
14
|
-
|
15
|
-
| 6.0.0
|
16
|
-
| 6.4.
|
78
|
+
| logstash-output-amazon_es | Logstash |
|
79
|
+
|---------------------------|----------|
|
80
|
+
| 6.0.0 | < 6.0.0 |
|
81
|
+
| 6.4.2 | >= 6.0.0 |
|
82
|
+
| 7.0.1 | >= 7.0.0 |
|
83
|
+
| 7.1.0 | >= 7.0.0 |
|
84
|
+
| 8.0.0 | >= 7.0.0 |
|
17
85
|
|
18
|
-
logstash-output-amazon_es plugin versions 6.4.0 and newer are tested to be compatible with Elasticsearch 6.5 and greater.
|
86
|
+
Also, logstash-output-amazon_es plugin versions 6.4.0 and newer are tested to be compatible with Elasticsearch 6.5 and greater.
|
87
|
+
|
88
|
+
| logstash-output-amazon_es | Elasticsearch |
|
89
|
+
| ------------- |----------|
|
90
|
+
| 6.4.0+ | 6.5+ |
|
91
|
+
|
92
|
+
|
93
|
+
## Installation
|
94
|
+
|
95
|
+
To install the latest version, use the normal Logstash plugin script.
|
96
|
+
|
97
|
+
```sh
|
98
|
+
bin/logstash-plugin install logstash-output-amazon_es
|
99
|
+
```
|
100
|
+
|
101
|
+
If you want to use old version of logstash-output-amazon_es, you can use the `--version`
|
102
|
+
flag to specify the version. For example:
|
103
|
+
|
104
|
+
```sh
|
105
|
+
bin/logstash-plugin install --version 6.4.2 logstash-output-amazon_es
|
106
|
+
```
|
107
|
+
|
108
|
+
Starting in 8.0.0, the aws sdk version is bumped to v3. In order for all other AWS plugins to work together, please remove pre-installed plugins and install logstash-integration-aws plugin as follows. See also https://github.com/logstash-plugins/logstash-mixin-aws/issues/38
|
109
|
+
```
|
110
|
+
# Remove existing logstash aws plugins and install logstash-integration-aws to keep sdk dependency the same
|
111
|
+
# https://github.com/logstash-plugins/logstash-mixin-aws/issues/38
|
112
|
+
/usr/share/logstash/bin/logstash-plugin remove logstash-input-s3
|
113
|
+
/usr/share/logstash/bin/logstash-plugin remove logstash-input-sqs
|
114
|
+
/usr/share/logstash/bin/logstash-plugin remove logstash-output-s3
|
115
|
+
/usr/share/logstash/bin/logstash-plugin remove logstash-output-sns
|
116
|
+
/usr/share/logstash/bin/logstash-plugin remove logstash-output-sqs
|
117
|
+
/usr/share/logstash/bin/logstash-plugin remove logstash-output-cloudwatch
|
118
|
+
|
119
|
+
/usr/share/logstash/bin/logstash-plugin install --version 0.1.0.pre logstash-integration-aws
|
120
|
+
bin/logstash-plugin install --version 8.0.0 logstash-output-amazon_es
|
121
|
+
```
|
19
122
|
|
20
123
|
## Configuration for Amazon Elasticsearch Service Output Plugin
|
21
124
|
|
@@ -62,17 +165,36 @@ output {
|
|
62
165
|
- max_bulk_bytes - The max size for a bulk request in bytes. Default is 20MB. It is recommended not to change this value unless needed. For guidance on changing this value, please consult the table for network limits for your instance type: https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/aes-limits.html#network-limits
|
63
166
|
|
64
167
|
After 6.4.0, users can't set batch size in this output plugin config. However, users can still set batch size in logstash.yml file.
|
168
|
+
|
169
|
+
### Advanced Optional Parameters
|
170
|
+
|
171
|
+
Starting logstash-output-amazon_es v7.1.0, we have introduced the following optional parameters to resolve specific use cases:
|
172
|
+
|
173
|
+
- service_name (string, default => "es") - Users can define any service name to which the plugin will send a SigV4 signed request
|
174
|
+
- skip_healthcheck (boolean, default => false) - Boolean to skip healthcheck API and set the major ES version to 7
|
175
|
+
- skip_template_installation (boolean, default => false) - Boolean to allow users to skip installing templates in usecases that don't require them
|
176
|
+
|
65
177
|
## Developing
|
66
178
|
|
67
|
-
### 1.
|
179
|
+
### 1. Prerequisites
|
180
|
+
To get started, you can install JRuby with the Bundler gem using [RVM](https://rvm.io/rvm/install)
|
181
|
+
|
182
|
+
```shell
|
183
|
+
rvm install jruby-9.2.5.0
|
184
|
+
```
|
185
|
+
|
186
|
+
### 2. Plugin Development and Testing
|
68
187
|
|
69
188
|
#### Code
|
70
189
|
|
71
|
-
1.
|
190
|
+
1. Verify JRuby is already installed
|
72
191
|
|
73
|
-
|
192
|
+
```sh
|
193
|
+
jruby -v
|
194
|
+
```
|
74
195
|
|
75
|
-
|
196
|
+
|
197
|
+
2. Install dependencies:
|
76
198
|
|
77
199
|
```sh
|
78
200
|
bundle install
|
@@ -92,14 +214,14 @@ After 6.4.0, users can't set batch size in this output plugin config. However, u
|
|
92
214
|
bundle exec rspec
|
93
215
|
```
|
94
216
|
|
95
|
-
###
|
217
|
+
### 3. Running your unpublished plugin in Logstash
|
96
218
|
|
97
|
-
####
|
219
|
+
#### 3.1 Run in a local Logstash clone
|
98
220
|
|
99
221
|
1. Edit Logstash `Gemfile` and add the local plugin path, for example:
|
100
222
|
|
101
223
|
```ruby
|
102
|
-
gem "logstash-
|
224
|
+
gem "logstash-output-amazon_es", :path => "/your/local/logstash-output-amazon_es"
|
103
225
|
```
|
104
226
|
|
105
227
|
2. Install the plugin:
|
@@ -115,12 +237,12 @@ After 6.4.0, users can't set batch size in this output plugin config. However, u
|
|
115
237
|
3. Run Logstash with your plugin:
|
116
238
|
|
117
239
|
```sh
|
118
|
-
bin/logstash -e '
|
240
|
+
bin/logstash -e 'output {amazon_es {}}'
|
119
241
|
```
|
120
242
|
|
121
243
|
At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply re-run Logstash.
|
122
244
|
|
123
|
-
####
|
245
|
+
#### 3.2 Run in an installed Logstash
|
124
246
|
|
125
247
|
Before build your `Gemfile`, please make sure use JRuby. Here is how you can know your local Ruby version:
|
126
248
|
|
@@ -131,37 +253,25 @@ rvm list
|
|
131
253
|
Please make sure you current using JRuby. Here is how you can change to JRuby
|
132
254
|
|
133
255
|
```sh
|
134
|
-
rvm jruby
|
256
|
+
rvm jruby-9.2.5.0
|
135
257
|
```
|
136
258
|
|
137
|
-
You can use the same **
|
259
|
+
You can use the same **3.1** method to run your plugin in an installed Logstash by editing its `Gemfile` and pointing the `:path` to your local plugin development directory. You can also build the gem and install it using:
|
138
260
|
|
139
261
|
1. Build your plugin gem:
|
140
262
|
|
141
263
|
```sh
|
142
|
-
gem build logstash-
|
264
|
+
gem build logstash-output-amazon_es.gemspec
|
143
265
|
```
|
144
266
|
|
145
|
-
2. Install the plugin from the Logstash home:
|
267
|
+
2. Install the plugin from the Logstash home. Please be sure to check the version number against the actual Gem file. Run:
|
146
268
|
|
147
269
|
```sh
|
148
|
-
|
149
|
-
bin/logstash-plugin install --no-verify
|
150
|
-
|
151
|
-
# Prior to Logstash 2.3
|
152
|
-
bin/plugin install --no-verify
|
270
|
+
bin/logstash-plugin install /your/local/logstash-output-amazon_es/logstash-output-amazon_es-7.0.1-java.gem
|
153
271
|
```
|
154
272
|
|
155
273
|
3. Start Logstash and test the plugin.
|
156
274
|
|
157
|
-
## Old version support
|
158
|
-
|
159
|
-
If you want to use old version of logstash-output-amazon_es, you can install with this:
|
160
|
-
```sh
|
161
|
-
bin/logstash-plugin install logstash-output-amazon_es -v 2.0.0
|
162
|
-
```
|
163
|
-
|
164
|
-
|
165
275
|
|
166
276
|
## Contributing
|
167
277
|
|
@@ -1,8 +1,12 @@
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
2
|
+
# See NOTICE for attribution details.
|
3
|
+
# Modifications Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4
|
+
|
1
5
|
require "logstash/outputs/amazon_es/template_manager"
|
2
6
|
|
3
7
|
module LogStash; module Outputs; class AmazonElasticSearch;
|
4
8
|
module Common
|
5
|
-
attr_reader :client, :hosts
|
9
|
+
attr_reader :client, :hosts, :skip_template_installation
|
6
10
|
|
7
11
|
# These codes apply to documents, not at the request level
|
8
12
|
DOC_DLQ_CODES = [400, 404]
|
@@ -115,8 +119,12 @@ module LogStash; module Outputs; class AmazonElasticSearch;
|
|
115
119
|
end
|
116
120
|
|
117
121
|
def install_template
|
118
|
-
|
119
|
-
|
122
|
+
if skip_template_installation == false
|
123
|
+
TemplateManager.install_template(self)
|
124
|
+
@template_installed.make_true
|
125
|
+
elsif skip_template_installation == true
|
126
|
+
@template_installed.make_true
|
127
|
+
end
|
120
128
|
end
|
121
129
|
|
122
130
|
def check_action_validity
|
@@ -1,3 +1,7 @@
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
2
|
+
# See NOTICE for attribution details.
|
3
|
+
# Modifications Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4
|
+
|
1
5
|
require 'forwardable' # Needed for logstash core SafeURI. We need to patch this in core: https://github.com/elastic/logstash/pull/5978
|
2
6
|
|
3
7
|
module LogStash; module Outputs; class AmazonElasticSearch
|
@@ -1,3 +1,7 @@
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
2
|
+
# See NOTICE for attribution details.
|
3
|
+
# Modifications Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4
|
+
|
1
5
|
require 'manticore'
|
2
6
|
require 'cgi'
|
3
7
|
require 'aws-sdk-core'
|
@@ -33,6 +37,7 @@ module LogStash; module Outputs; class AmazonElasticSearch; class HttpClient;
|
|
33
37
|
@port = options[:port] || 9200
|
34
38
|
@protocol = options[:protocol] || 'http'
|
35
39
|
@region = options[:region] || 'us-east-1'
|
40
|
+
@service_name = options[:service_name] || 'es'
|
36
41
|
aws_access_key_id = options[:aws_access_key_id] || nil
|
37
42
|
aws_secret_access_key = options[:aws_secret_access_key] || nil
|
38
43
|
session_token = options[:session_token] || nil
|
@@ -46,10 +51,10 @@ module LogStash; module Outputs; class AmazonElasticSearch; class HttpClient;
|
|
46
51
|
if options[:proxy]
|
47
52
|
options[:proxy] = manticore_proxy_hash(options[:proxy])
|
48
53
|
end
|
49
|
-
|
54
|
+
|
50
55
|
@manticore = ::Manticore::Client.new(options)
|
51
56
|
end
|
52
|
-
|
57
|
+
|
53
58
|
# Transform the proxy option to a hash. Manticore's support for non-hash
|
54
59
|
# proxy options is broken. This was fixed in https://github.com/cheald/manticore/commit/34a00cee57a56148629ed0a47c329181e7319af5
|
55
60
|
# but this is not yet released
|
@@ -84,12 +89,12 @@ module LogStash; module Outputs; class AmazonElasticSearch; class HttpClient;
|
|
84
89
|
params[:body] = body if body
|
85
90
|
|
86
91
|
if url.user
|
87
|
-
params[:auth] = {
|
92
|
+
params[:auth] = {
|
88
93
|
:user => CGI.unescape(url.user),
|
89
94
|
# We have to unescape the password here since manticore won't do it
|
90
95
|
# for us unless its part of the URL
|
91
|
-
:password => CGI.unescape(url.password),
|
92
|
-
:eager => true
|
96
|
+
:password => CGI.unescape(url.password),
|
97
|
+
:eager => true
|
93
98
|
}
|
94
99
|
end
|
95
100
|
|
@@ -102,16 +107,18 @@ module LogStash; module Outputs; class AmazonElasticSearch; class HttpClient;
|
|
102
107
|
end
|
103
108
|
|
104
109
|
|
105
|
-
|
110
|
+
request = Seahorse::Client::Http::Request.new(options={:endpoint=>url, :http_method => method.to_s.upcase,
|
106
111
|
:headers => params[:headers],:body => params[:body]})
|
107
112
|
|
108
|
-
aws_signer = Aws::
|
109
|
-
|
110
|
-
|
111
|
-
signed_key = aws_signer.sign(key)
|
112
|
-
params[:headers] = params[:headers].merge(signed_key.headers)
|
113
|
-
|
113
|
+
aws_signer = Aws::Sigv4::Signer.new(service: @service_name, region: @region, credentials_provider: @credentials)
|
114
114
|
|
115
|
+
signed_key = aws_signer.sign_request(
|
116
|
+
http_method: request.http_method,
|
117
|
+
url: url,
|
118
|
+
headers: params[:headers],
|
119
|
+
body: params[:body]
|
120
|
+
)
|
121
|
+
params[:headers] = params[:headers].merge(signed_key.headers)
|
115
122
|
|
116
123
|
resp = @manticore.send(method.downcase, request_uri.to_s, params)
|
117
124
|
|
@@ -131,27 +138,27 @@ module LogStash; module Outputs; class AmazonElasticSearch; class HttpClient;
|
|
131
138
|
|
132
139
|
def format_url(url, path_and_query=nil)
|
133
140
|
request_uri = url.clone
|
134
|
-
|
141
|
+
|
135
142
|
# We excise auth info from the URL in case manticore itself tries to stick
|
136
143
|
# sensitive data in a thrown exception or log data
|
137
144
|
request_uri.user = nil
|
138
145
|
request_uri.password = nil
|
139
146
|
|
140
147
|
return request_uri.to_s if path_and_query.nil?
|
141
|
-
|
148
|
+
|
142
149
|
parsed_path_and_query = java.net.URI.new(path_and_query)
|
143
|
-
|
150
|
+
|
144
151
|
query = request_uri.query
|
145
152
|
parsed_query = parsed_path_and_query.query
|
146
|
-
|
153
|
+
|
147
154
|
new_query_parts = [request_uri.query, parsed_path_and_query.query].select do |part|
|
148
155
|
part && !part.empty? # Skip empty nil and ""
|
149
156
|
end
|
150
|
-
|
157
|
+
|
151
158
|
request_uri.query = new_query_parts.join("&") unless new_query_parts.empty?
|
152
|
-
|
159
|
+
|
153
160
|
request_uri.path = "#{request_uri.path}/#{parsed_path_and_query.path}".gsub(/\/{2,}/, "/")
|
154
|
-
|
161
|
+
|
155
162
|
request_uri
|
156
163
|
end
|
157
164
|
|
@@ -1,3 +1,7 @@
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
2
|
+
# See NOTICE for attribution details.
|
3
|
+
# Modifications Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4
|
+
|
1
5
|
module LogStash; module Outputs; class AmazonElasticSearch; class HttpClient;
|
2
6
|
class Pool
|
3
7
|
class NoConnectionAvailableError < Error; end
|
@@ -28,7 +32,7 @@ module LogStash; module Outputs; class AmazonElasticSearch; class HttpClient;
|
|
28
32
|
end
|
29
33
|
end
|
30
34
|
|
31
|
-
attr_reader :logger, :adapter, :sniffing, :sniffer_delay, :resurrect_delay, :healthcheck_path, :sniffing_path, :bulk_path
|
35
|
+
attr_reader :logger, :adapter, :sniffing, :sniffer_delay, :resurrect_delay, :healthcheck_path, :sniffing_path, :bulk_path, :skip_healthcheck
|
32
36
|
|
33
37
|
ROOT_URI_PATH = '/'.freeze
|
34
38
|
|
@@ -40,6 +44,7 @@ module LogStash; module Outputs; class AmazonElasticSearch; class HttpClient;
|
|
40
44
|
:resurrect_delay => 5,
|
41
45
|
:sniffing => false,
|
42
46
|
:sniffer_delay => 10,
|
47
|
+
:skip_healthcheck => false,
|
43
48
|
}.freeze
|
44
49
|
|
45
50
|
def initialize(logger, adapter, initial_urls=[], options={})
|
@@ -57,6 +62,7 @@ module LogStash; module Outputs; class AmazonElasticSearch; class HttpClient;
|
|
57
62
|
@resurrect_delay = merged[:resurrect_delay]
|
58
63
|
@sniffing = merged[:sniffing]
|
59
64
|
@sniffer_delay = merged[:sniffer_delay]
|
65
|
+
@skip_healthcheck = merged[:skip_healthcheck]
|
60
66
|
end
|
61
67
|
|
62
68
|
# Used for all concurrent operations in this class
|
@@ -238,25 +244,30 @@ module LogStash; module Outputs; class AmazonElasticSearch; class HttpClient;
|
|
238
244
|
|
239
245
|
def healthcheck!
|
240
246
|
# Try to keep locking granularity low such that we don't affect IO...
|
241
|
-
@state_mutex.synchronize { @url_info.select {|url,meta| meta[:state] != :alive } }.each do |url,meta|
|
247
|
+
@state_mutex.synchronize { @url_info.select { |url, meta| meta[:state] != :alive } }.each do |url, meta|
|
242
248
|
begin
|
243
|
-
|
249
|
+
if skip_healthcheck == false
|
250
|
+
logger.info("Running health check to see if an Elasticsearch connection is working",
|
244
251
|
:healthcheck_url => url, :path => @healthcheck_path)
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
252
|
+
response = perform_request_to_url(url, :head, @healthcheck_path)
|
253
|
+
# If no exception was raised it must have succeeded!
|
254
|
+
logger.warn("Restored connection to ES instance", :url => url.sanitized.to_s)
|
255
|
+
# We reconnected to this node, check its ES version
|
256
|
+
es_version = get_es_version(url)
|
257
|
+
@state_mutex.synchronize do
|
258
|
+
meta[:version] = es_version
|
259
|
+
major = major_version(es_version)
|
260
|
+
if !@maximum_seen_major_version
|
261
|
+
@logger.info("ES Output version determined", :es_version => major)
|
262
|
+
set_new_major_version(major)
|
263
|
+
elsif major > @maximum_seen_major_version
|
264
|
+
@logger.warn("Detected a node with a higher major version than previously observed. This could be the result of an amazon_es cluster upgrade.", :previous_major => @maximum_seen_major_version, :new_major => major, :node_url => url)
|
265
|
+
set_new_major_version(major)
|
266
|
+
end
|
267
|
+
meta[:state] = :alive
|
259
268
|
end
|
269
|
+
elsif skip_healthcheck == true
|
270
|
+
set_new_major_version(7)
|
260
271
|
meta[:state] = :alive
|
261
272
|
end
|
262
273
|
rescue HostUnreachableError, BadResponseCodeError => e
|
@@ -1,3 +1,7 @@
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
2
|
+
# See NOTICE for attribution details.
|
3
|
+
# Modifications Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4
|
+
|
1
5
|
require "logstash/outputs/amazon_es"
|
2
6
|
require "cabin"
|
3
7
|
require "base64"
|
@@ -25,7 +29,7 @@ module LogStash; module Outputs; class AmazonElasticSearch;
|
|
25
29
|
# * `:user` - String. The user to use for authentication.
|
26
30
|
# * `:password` - String. The password to use for authentication.
|
27
31
|
# * `:timeout` - Float. A duration value, in seconds, after which a socket
|
28
|
-
# operation or request will be aborted if not yet
|
32
|
+
# operation or request will be aborted if not yet successful
|
29
33
|
# * `:client_settings` - a hash; see below for keys.
|
30
34
|
#
|
31
35
|
# The `client_settings` key is a has that can contain other settings:
|
@@ -272,6 +276,8 @@ module LogStash; module Outputs; class AmazonElasticSearch;
|
|
272
276
|
|
273
277
|
adapter_options[:region] = options[:region]
|
274
278
|
|
279
|
+
adapter_options[:service_name] = options[:service_name]
|
280
|
+
|
275
281
|
adapter_options[:port] = options[:port]
|
276
282
|
|
277
283
|
adapter_options[:protocol] = options[:protocol]
|
@@ -294,7 +300,8 @@ module LogStash; module Outputs; class AmazonElasticSearch;
|
|
294
300
|
:healthcheck_path => options[:healthcheck_path],
|
295
301
|
:resurrect_delay => options[:resurrect_delay],
|
296
302
|
:url_normalizer => self.method(:host_to_url),
|
297
|
-
:metric => options[:metric]
|
303
|
+
:metric => options[:metric],
|
304
|
+
:skip_healthcheck => options[:skip_healthcheck],
|
298
305
|
}
|
299
306
|
pool_options[:scheme] = self.scheme if self.scheme
|
300
307
|
|
@@ -1,3 +1,7 @@
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
2
|
+
# See NOTICE for attribution details.
|
3
|
+
# Modifications Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4
|
+
|
1
5
|
require 'cgi'
|
2
6
|
|
3
7
|
module LogStash; module Outputs; class AmazonElasticSearch;
|
@@ -100,9 +104,11 @@ module LogStash; module Outputs; class AmazonElasticSearch;
|
|
100
104
|
:protocol => params["protocol"],
|
101
105
|
:port => params["port"],
|
102
106
|
:region => params["region"],
|
107
|
+
:service_name => params["service_name"],
|
103
108
|
:aws_access_key_id => params["aws_access_key_id"],
|
104
109
|
:aws_secret_access_key => params["aws_secret_access_key"],
|
105
|
-
:max_bulk_bytes => params["max_bulk_bytes"]
|
110
|
+
:max_bulk_bytes => params["max_bulk_bytes"],
|
111
|
+
:skip_healthcheck => params["skip_healthcheck"])
|
106
112
|
)
|
107
113
|
end
|
108
114
|
|
@@ -1,3 +1,7 @@
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
2
|
+
# See NOTICE for attribution details.
|
3
|
+
# Modifications Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4
|
+
|
1
5
|
module LogStash; module Outputs; class AmazonElasticSearch
|
2
6
|
class TemplateManager
|
3
7
|
# To be mixed into the amazon_es plugin base
|
@@ -1,3 +1,7 @@
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
2
|
+
# See NOTICE for attribution details.
|
3
|
+
# Modifications Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4
|
+
|
1
5
|
# encoding: utf-8
|
2
6
|
require "logstash/namespace"
|
3
7
|
require "logstash/environment"
|
@@ -121,11 +125,14 @@ class LogStash::Outputs::AmazonElasticSearch < LogStash::Outputs::Base
|
|
121
125
|
# You can set the remote port as part of the host, or explicitly here as well
|
122
126
|
config :port, :validate => :number, :default => 443
|
123
127
|
|
124
|
-
# Sets the protocol thats used to connect to
|
128
|
+
# Sets the protocol thats used to connect to elasticsearch
|
125
129
|
config :protocol, :validate => :string, :default => "https"
|
126
130
|
|
127
131
|
#Signing specific details
|
128
132
|
config :region, :validate => :string, :default => "us-east-1"
|
133
|
+
|
134
|
+
#Service name, default is `es`
|
135
|
+
config :service_name, :validate => :string, :default => "es"
|
129
136
|
# Credential resolution logic works as follows:
|
130
137
|
#
|
131
138
|
# - User passed aws_access_key_id and aws_secret_access_key in aes configuration
|
@@ -251,6 +258,12 @@ class LogStash::Outputs::AmazonElasticSearch < LogStash::Outputs::Base
|
|
251
258
|
#Max bulk size in bytes
|
252
259
|
config :max_bulk_bytes, :validate => :number, :default => 20 * 1024 * 1024
|
253
260
|
|
261
|
+
#Option for user to skip Healthcheck API for a host when set to True
|
262
|
+
config :skip_healthcheck, :validate => :boolean, :default => false
|
263
|
+
|
264
|
+
#Allow user to skip installing template when set to True
|
265
|
+
config :skip_template_installation, :validate => :boolean, :default => false
|
266
|
+
|
254
267
|
def build_client
|
255
268
|
params["metric"] = metric
|
256
269
|
@client ||= ::LogStash::Outputs::AmazonElasticSearch::HttpClientBuilder.build(@logger, @hosts, params)
|
@@ -1,6 +1,10 @@
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
2
|
+
# See NOTICE for attribution details.
|
3
|
+
# Modifications Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4
|
+
|
1
5
|
Gem::Specification.new do |s|
|
2
6
|
s.name = 'logstash-output-amazon_es'
|
3
|
-
s.version = '
|
7
|
+
s.version = '8.0.0'
|
4
8
|
s.licenses = ['Apache-2.0']
|
5
9
|
s.summary = "Logstash Output to Amazon Elasticsearch Service"
|
6
10
|
s.description = "Output events to Amazon Elasticsearch Service with V4 signing"
|
@@ -24,7 +28,7 @@ Gem::Specification.new do |s|
|
|
24
28
|
s.add_runtime_dependency 'stud', ['>= 0.0.17', '~> 0.0']
|
25
29
|
s.add_runtime_dependency 'cabin', ['~> 0.6']
|
26
30
|
s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
|
27
|
-
s.add_runtime_dependency 'aws-sdk', '
|
31
|
+
s.add_runtime_dependency 'aws-sdk', '~> 3'
|
28
32
|
|
29
33
|
s.add_development_dependency 'logstash-codec-plain'
|
30
34
|
s.add_development_dependency 'logstash-devutils', "~> 1.3", ">= 1.3.1"
|
data/spec/es_spec_helper.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
2
|
+
# See NOTICE for attribution details.
|
3
|
+
# Modifications Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4
|
+
|
1
5
|
require "logstash/devutils/rspec/spec_helper"
|
2
6
|
require "logstash/outputs/amazon_es"
|
3
7
|
require "logstash/outputs/amazon_es/http_client"
|
@@ -1,3 +1,7 @@
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
2
|
+
# See NOTICE for attribution details.
|
3
|
+
# Modifications Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4
|
+
|
1
5
|
require "logstash/devutils/rspec/spec_helper"
|
2
6
|
require "logstash/outputs/amazon_es/http_client"
|
3
7
|
require "json"
|
@@ -1,3 +1,7 @@
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
2
|
+
# See NOTICE for attribution details.
|
3
|
+
# Modifications Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4
|
+
|
1
5
|
require "logstash/devutils/rspec/spec_helper"
|
2
6
|
require "logstash/outputs/amazon_es/http_client"
|
3
7
|
require "java"
|
@@ -1,3 +1,7 @@
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
2
|
+
# See NOTICE for attribution details.
|
3
|
+
# Modifications Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4
|
+
|
1
5
|
require "logstash/devutils/rspec/spec_helper"
|
2
6
|
require "logstash/outputs/amazon_es/http_client"
|
3
7
|
require "java"
|
@@ -1,3 +1,7 @@
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
2
|
+
# See NOTICE for attribution details.
|
3
|
+
# Modifications Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
4
|
+
|
1
5
|
require_relative "../../../spec/es_spec_helper"
|
2
6
|
require "flores/random"
|
3
7
|
require "logstash/outputs/amazon_es"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-amazon_es
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 8.0.0
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Amazon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -20,8 +20,8 @@ dependencies:
|
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: 1.0.0
|
22
22
|
name: manticore
|
23
|
-
prerelease: false
|
24
23
|
type: :runtime
|
24
|
+
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
@@ -33,23 +33,23 @@ dependencies:
|
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
requirement: !ruby/object:Gem::Requirement
|
35
35
|
requirements:
|
36
|
-
- - ">="
|
37
|
-
- !ruby/object:Gem::Version
|
38
|
-
version: 0.0.17
|
39
36
|
- - "~>"
|
40
37
|
- !ruby/object:Gem::Version
|
41
38
|
version: '0.0'
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 0.0.17
|
42
42
|
name: stud
|
43
|
-
prerelease: false
|
44
43
|
type: :runtime
|
44
|
+
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- - ">="
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: 0.0.17
|
50
47
|
- - "~>"
|
51
48
|
- !ruby/object:Gem::Version
|
52
49
|
version: '0.0'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 0.0.17
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
requirement: !ruby/object:Gem::Requirement
|
55
55
|
requirements:
|
@@ -57,8 +57,8 @@ dependencies:
|
|
57
57
|
- !ruby/object:Gem::Version
|
58
58
|
version: '0.6'
|
59
59
|
name: cabin
|
60
|
-
prerelease: false
|
61
60
|
type: :runtime
|
61
|
+
prerelease: false
|
62
62
|
version_requirements: !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
64
|
- - "~>"
|
@@ -74,8 +74,8 @@ dependencies:
|
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '2.99'
|
76
76
|
name: logstash-core-plugin-api
|
77
|
-
prerelease: false
|
78
77
|
type: :runtime
|
78
|
+
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
81
|
- - ">="
|
@@ -87,23 +87,17 @@ dependencies:
|
|
87
87
|
- !ruby/object:Gem::Dependency
|
88
88
|
requirement: !ruby/object:Gem::Requirement
|
89
89
|
requirements:
|
90
|
-
- - ">="
|
91
|
-
- !ruby/object:Gem::Version
|
92
|
-
version: 2.3.22
|
93
90
|
- - "~>"
|
94
91
|
- !ruby/object:Gem::Version
|
95
|
-
version: '
|
92
|
+
version: '3'
|
96
93
|
name: aws-sdk
|
97
|
-
prerelease: false
|
98
94
|
type: :runtime
|
95
|
+
prerelease: false
|
99
96
|
version_requirements: !ruby/object:Gem::Requirement
|
100
97
|
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: 2.3.22
|
104
98
|
- - "~>"
|
105
99
|
- !ruby/object:Gem::Version
|
106
|
-
version: '
|
100
|
+
version: '3'
|
107
101
|
- !ruby/object:Gem::Dependency
|
108
102
|
requirement: !ruby/object:Gem::Requirement
|
109
103
|
requirements:
|
@@ -111,8 +105,8 @@ dependencies:
|
|
111
105
|
- !ruby/object:Gem::Version
|
112
106
|
version: '0'
|
113
107
|
name: logstash-codec-plain
|
114
|
-
prerelease: false
|
115
108
|
type: :development
|
109
|
+
prerelease: false
|
116
110
|
version_requirements: !ruby/object:Gem::Requirement
|
117
111
|
requirements:
|
118
112
|
- - ">="
|
@@ -128,8 +122,8 @@ dependencies:
|
|
128
122
|
- !ruby/object:Gem::Version
|
129
123
|
version: 1.3.1
|
130
124
|
name: logstash-devutils
|
131
|
-
prerelease: false
|
132
125
|
type: :development
|
126
|
+
prerelease: false
|
133
127
|
version_requirements: !ruby/object:Gem::Requirement
|
134
128
|
requirements:
|
135
129
|
- - "~>"
|
@@ -145,8 +139,8 @@ dependencies:
|
|
145
139
|
- !ruby/object:Gem::Version
|
146
140
|
version: '0'
|
147
141
|
name: flores
|
148
|
-
prerelease: false
|
149
142
|
type: :development
|
143
|
+
prerelease: false
|
150
144
|
version_requirements: !ruby/object:Gem::Requirement
|
151
145
|
requirements:
|
152
146
|
- - "~>"
|
@@ -205,8 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
205
199
|
- !ruby/object:Gem::Version
|
206
200
|
version: '0'
|
207
201
|
requirements: []
|
208
|
-
|
209
|
-
rubygems_version: 2.7.6
|
202
|
+
rubygems_version: 3.0.1
|
210
203
|
signing_key:
|
211
204
|
specification_version: 4
|
212
205
|
summary: Logstash Output to Amazon Elasticsearch Service
|