logstash-output-opensearch 1.0.0-java → 1.1.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/COMPATIBILITY.md +27 -0
- data/CONTRIBUTING.md +1 -5
- data/DEVELOPER_GUIDE.md +7 -7
- data/NOTICE +9 -2
- data/README.md +3 -3
- data/lib/logstash/outputs/opensearch/http_client/manticore_adapter.rb +1 -1
- data/lib/logstash/outputs/opensearch/http_client/pool.rb +3 -16
- data/lib/logstash/outputs/opensearch/http_client.rb +0 -1
- data/lib/logstash/outputs/opensearch/http_client_builder.rb +0 -1
- data/lib/logstash/outputs/opensearch.rb +1 -2
- data/lib/logstash/plugin_mixins/opensearch/common.rb +2 -2
- data/logstash-output-opensearch.gemspec +4 -4
- data/spec/integration/outputs/compressed_indexing_spec.rb +1 -1
- data/spec/integration/outputs/index_spec.rb +2 -2
- data/spec/integration/outputs/ingest_pipeline_spec.rb +1 -1
- data/spec/integration/outputs/parent_spec.rb +1 -1
- data/spec/unit/outputs/opensearch/http_client/manticore_adapter_spec.rb +1 -1
- data/spec/unit/outputs/opensearch/http_client/pool_spec.rb +4 -87
- data.tar.gz.sig +0 -0
- metadata +3 -4
- metadata.gz.sig +0 -0
- data/lib/logstash/outputs/opensearch/distribution_checker.rb +0 -44
- data/lib/logstash/plugin_mixins/opensearch/noop_distribution_checker.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de9f143d61a40ce521ac3500f2af934aa8a8d0da3cea50ac74b48f410ec54107
|
4
|
+
data.tar.gz: 46195137ee6c66e9fcc2b9a24f1ff474bf1444c4e5507560373dcf695014be64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e96a1a3e78e07b6b74134483eb5ad6353c356a1f322a8b82222489241ecf3bcd59550885759217231973ac450fc3b284e38719c0e23bf80cfb54b8ee2dafdfad
|
7
|
+
data.tar.gz: 1ed119eefce3e7666f58e3cc57850c3809ec9dbbc7d6603f67808bd8d07a598c498580f5195c2aa361b4ee09cd6d49fb05170aa98d3faaf249a9c633876193e0
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/COMPATIBILITY.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
## Compatibility
|
2
|
+
|
3
|
+
### Matrix for Logstash OSS
|
4
|
+
|
5
|
+
| logstash-output-opensearch | Logstash OSS|
|
6
|
+
| ------------- | ------------- |
|
7
|
+
| 1.0.0+ | 7.13.2 |
|
8
|
+
|
9
|
+
### Matrix for OpenSearch
|
10
|
+
|
11
|
+
| logstash-output-opensearch | OpenSearch |
|
12
|
+
| ------------- | ------------- |
|
13
|
+
| 1.0.0+ | 1.0.0 |
|
14
|
+
|
15
|
+
|
16
|
+
### Matrix for ODFE
|
17
|
+
|
18
|
+
| logstash-output-opensearch | ODFE |
|
19
|
+
| ------------- | ------------- |
|
20
|
+
| 1.0.0+ | 1.x - 1.13.2 |
|
21
|
+
|
22
|
+
|
23
|
+
### Matrix for Elasticsearch OSS
|
24
|
+
|
25
|
+
| logstash-output-opensearch | Elasticsearch OSS|
|
26
|
+
| ------------- | ------------- |
|
27
|
+
| 1.0.0+ | 7.x - 7.10.2 |
|
data/CONTRIBUTING.md
CHANGED
@@ -35,17 +35,13 @@ If you've upgraded to the latest version and you can't find it in our open issue
|
|
35
35
|
|
36
36
|
If you've thought of a way that logstash-output-opensearch could be better, we want to hear about it. We track feature requests using GitHub, so please feel free to open an issue which describes the feature you would like to see, why you need it, and how it should work.
|
37
37
|
|
38
|
-
### Documentation Changes
|
39
|
-
|
40
|
-
//TODO
|
41
|
-
|
42
38
|
### Contributing Code
|
43
39
|
|
44
40
|
As with other types of contributions, the first step is to [**open an issue on GitHub**](https://github.com/opensearch-project/logstash-output-opensearch/issues/new/choose). Opening an issue before you make changes makes sure that someone else isn't already working on that particular problem. It also lets us all work together to find the right approach before you spend a bunch of time on a PR. So again, when in doubt, open an issue.
|
45
41
|
|
46
42
|
## Developer Certificate of Origin
|
47
43
|
|
48
|
-
logstash-output-opensearch is an open source product released under the Apache 2.0 license (see either [the Apache site](https://www.apache.org/licenses/LICENSE-2.0) or the [LICENSE
|
44
|
+
logstash-output-opensearch is an open source product released under the Apache 2.0 license (see either [the Apache site](https://www.apache.org/licenses/LICENSE-2.0) or the [LICENSE file](./LICENSE)). The Apache 2.0 license allows you to freely use, modify, distribute, and sell your own products that include Apache 2.0 licensed software.
|
49
45
|
|
50
46
|
We respect intellectual property rights of others and we want to make sure all incoming contributions are correctly attributed and licensed. A Developer Certificate of Origin (DCO) is a lightweight mechanism to do that.
|
51
47
|
|
data/DEVELOPER_GUIDE.md
CHANGED
@@ -59,7 +59,7 @@ Perform the following from your project root directory eg: `~/workspace/logstash
|
|
59
59
|
|
60
60
|
```bash
|
61
61
|
# Set up Environment variable for docker to pull your test environment
|
62
|
-
export LOGSTASH_VERSION=7.13.2 # will use
|
62
|
+
export LOGSTASH_VERSION=7.13.2 # will use 7.13.2 version if not specified.
|
63
63
|
|
64
64
|
# Set up docker ( this will build, install into Logstash )
|
65
65
|
scripts/unit-test/docker-setup.sh
|
@@ -73,8 +73,8 @@ scripts/unit-test/docker-run.sh
|
|
73
73
|
|
74
74
|
```bash
|
75
75
|
# Set up Environment variable for Docker to pull your test environment
|
76
|
-
export LOGSTASH_VERSION=7.13.2 # will use
|
77
|
-
export OPENSEARCH_VERSION=1.0.0
|
76
|
+
export LOGSTASH_VERSION=7.13.2 # will use 7.13.2 version if not specified.
|
77
|
+
export OPENSEARCH_VERSION=1.0.0 # will use latest if not specified.
|
78
78
|
|
79
79
|
# Set up docker ( this will build, install into Logstash )
|
80
80
|
scripts/opensearch/docker-setup.sh
|
@@ -87,8 +87,8 @@ scripts/opensearch/docker-run.sh
|
|
87
87
|
|
88
88
|
```bash
|
89
89
|
# Set up Environment variable for Docker to pull your test environment
|
90
|
-
export LOGSTASH_VERSION=7.13.2 # will use
|
91
|
-
export OPENSEARCH_VERSION=1.0.0
|
90
|
+
export LOGSTASH_VERSION=7.13.2 # will use 7.13.2 version if not specified.
|
91
|
+
export OPENSEARCH_VERSION=1.0.0 # will use latest if not specified.
|
92
92
|
export SECURE_INTEGRATION=true # to run against cluster with security plugin
|
93
93
|
# Set up docker ( this will build, install into Logstash )
|
94
94
|
scripts/opensearch/docker-setup.sh
|
@@ -101,7 +101,7 @@ scripts/opensearch/docker-run.sh
|
|
101
101
|
|
102
102
|
```bash
|
103
103
|
# Set up Environment variable for docker to pull your test environment
|
104
|
-
export LOGSTASH_VERSION=7.13.2 # will use
|
104
|
+
export LOGSTASH_VERSION=7.13.2 # will use 7.13.2 version if not specified.
|
105
105
|
export OPENDISTRO_VERSION=1.13.2 # will use latest if not specified.
|
106
106
|
|
107
107
|
# Set up docker ( this will build, install into Logstash )
|
@@ -188,7 +188,7 @@ To run the Logstash Output Opensearch plugin, add following configuration in you
|
|
188
188
|
```
|
189
189
|
output {
|
190
190
|
opensearch {
|
191
|
-
hosts => "
|
191
|
+
hosts => ["hostname:port"]
|
192
192
|
user => "admin"
|
193
193
|
password => "admin"
|
194
194
|
index => "logstash-logs-%{+YYYY.MM.dd}"
|
data/NOTICE
CHANGED
@@ -1,2 +1,9 @@
|
|
1
|
-
|
2
|
-
Copyright
|
1
|
+
OpenSearch (https://opensearch.org/)
|
2
|
+
Copyright OpenSearch Contributors
|
3
|
+
|
4
|
+
This product includes software developed by
|
5
|
+
Elasticsearch (http://www.elastic.co).
|
6
|
+
Copyright 2012-2015 Elasticsearch
|
7
|
+
|
8
|
+
This product includes software developed by The Apache Software
|
9
|
+
Foundation (http://www.apache.org/).
|
data/README.md
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
## Welcome!
|
12
12
|
|
13
|
-
**logstash-output-opensearch** is a community-driven, open source fork logstash-output-elasticsearch licensed under the [Apache v2.0 License](LICENSE
|
13
|
+
**logstash-output-opensearch** is a community-driven, open source fork logstash-output-elasticsearch licensed under the [Apache v2.0 License](LICENSE). For more information, see [opensearch.org](https://opensearch.org/).
|
14
14
|
|
15
15
|
## Project Resources
|
16
16
|
|
@@ -30,8 +30,8 @@ This project has adopted the [Amazon Open Source Code of Conduct](CODE_OF_CONDUC
|
|
30
30
|
|
31
31
|
## License
|
32
32
|
|
33
|
-
This project is licensed under the [Apache v2.0 License](LICENSE
|
33
|
+
This project is licensed under the [Apache v2.0 License](LICENSE).
|
34
34
|
|
35
35
|
## Copyright
|
36
36
|
|
37
|
-
Copyright
|
37
|
+
Copyright OpenSearch Contributors. See [NOTICE](NOTICE) for details.
|
@@ -11,7 +11,7 @@ require 'manticore'
|
|
11
11
|
require 'cgi'
|
12
12
|
|
13
13
|
module LogStash; module Outputs; class OpenSearch; class HttpClient;
|
14
|
-
DEFAULT_HEADERS = { "
|
14
|
+
DEFAULT_HEADERS = { "content-type" => "application/json" }
|
15
15
|
|
16
16
|
class ManticoreAdapter
|
17
17
|
attr_reader :manticore, :logger
|
@@ -8,7 +8,6 @@
|
|
8
8
|
# GitHub history for details.
|
9
9
|
|
10
10
|
require "concurrent/atomic/atomic_reference"
|
11
|
-
require "logstash/plugin_mixins/opensearch/noop_distribution_checker"
|
12
11
|
|
13
12
|
module LogStash; module Outputs; class OpenSearch; class HttpClient;
|
14
13
|
class Pool
|
@@ -41,7 +40,6 @@ module LogStash; module Outputs; class OpenSearch; class HttpClient;
|
|
41
40
|
end
|
42
41
|
|
43
42
|
attr_reader :logger, :adapter, :sniffing, :sniffer_delay, :resurrect_delay, :healthcheck_path, :sniffing_path, :bulk_path
|
44
|
-
attr_reader :distribution_checker
|
45
43
|
|
46
44
|
ROOT_URI_PATH = '/'.freeze
|
47
45
|
|
@@ -80,7 +78,6 @@ module LogStash; module Outputs; class OpenSearch; class HttpClient;
|
|
80
78
|
@stopping = false
|
81
79
|
|
82
80
|
@last_version = Concurrent::AtomicReference.new
|
83
|
-
@distribution_checker = options[:distribution_checker] || LogStash::PluginMixins::OpenSearch::NoopDistributionChecker::INSTANCE
|
84
81
|
end
|
85
82
|
|
86
83
|
def start
|
@@ -239,8 +236,7 @@ module LogStash; module Outputs; class OpenSearch; class HttpClient;
|
|
239
236
|
@state_mutex.synchronize do
|
240
237
|
meta[:version] = version
|
241
238
|
set_last_version(version, url)
|
242
|
-
|
243
|
-
meta[:state] = alive ? :alive : :dead
|
239
|
+
meta[:state] = :alive
|
244
240
|
end
|
245
241
|
rescue HostUnreachableError, BadResponseCodeError => e
|
246
242
|
logger.warn("Attempted to resurrect connection to dead OpenSearch instance, but got an error", url: url.sanitized.to_s, exception: e.class, message: e.message)
|
@@ -415,18 +411,9 @@ module LogStash; module Outputs; class OpenSearch; class HttpClient;
|
|
415
411
|
end
|
416
412
|
end
|
417
413
|
|
418
|
-
def get_version_map(url)
|
419
|
-
request = perform_request_to_url(url, :get, ROOT_URI_PATH)
|
420
|
-
LogStash::Json.load(request.body)['version']
|
421
|
-
end
|
422
|
-
|
423
414
|
def get_version(url)
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
def get_distribution(url)
|
428
|
-
version_map = get_version_map(url)
|
429
|
-
version_map.has_key?('distribution') ? version_map['distribution'] : version_map['build_flavor'] # e.g. "opensearch or oss"
|
415
|
+
request = perform_request_to_url(url, :get, ROOT_URI_PATH)
|
416
|
+
LogStash::Json.load(request.body)["version"]["number"] # e.g. "7.10.0"
|
430
417
|
end
|
431
418
|
|
432
419
|
def last_version
|
@@ -332,7 +332,6 @@ module LogStash; module Outputs; class OpenSearch;
|
|
332
332
|
adapter = build_adapter(options)
|
333
333
|
|
334
334
|
pool_options = {
|
335
|
-
:distribution_checker => options[:distribution_checker],
|
336
335
|
:sniffing => sniffing,
|
337
336
|
:sniffer_delay => options[:sniffer_delay],
|
338
337
|
:sniffing_path => options[:sniffing_path],
|
@@ -24,7 +24,6 @@ module LogStash; module Outputs; class OpenSearch;
|
|
24
24
|
client_settings[:proxy] = params["proxy"] if params["proxy"]
|
25
25
|
|
26
26
|
common_options = {
|
27
|
-
:distribution_checker => params["distribution_checker"],
|
28
27
|
:client_settings => client_settings,
|
29
28
|
:metric => params["metric"],
|
30
29
|
:resurrect_delay => params["resurrect_delay"]
|
@@ -68,7 +68,6 @@ require "forwardable"
|
|
68
68
|
class LogStash::Outputs::OpenSearch < LogStash::Outputs::Base
|
69
69
|
declare_threadsafe!
|
70
70
|
|
71
|
-
require "logstash/outputs/opensearch/distribution_checker"
|
72
71
|
require "logstash/outputs/opensearch/http_client"
|
73
72
|
require "logstash/outputs/opensearch/http_client_builder"
|
74
73
|
require "logstash/plugin_mixins/opensearch/api_configs"
|
@@ -218,7 +217,7 @@ class LogStash::Outputs::OpenSearch < LogStash::Outputs::Base
|
|
218
217
|
|
219
218
|
@logger.info("New OpenSearch output", :class => self.class.name, :hosts => @hosts.map(&:sanitized).map(&:to_s))
|
220
219
|
|
221
|
-
@client = build_client
|
220
|
+
@client = build_client
|
222
221
|
|
223
222
|
@after_successful_connection_thread = after_successful_connection do
|
224
223
|
begin
|
@@ -24,8 +24,8 @@ module LogStash; module PluginMixins; module OpenSearch
|
|
24
24
|
# Perform some OpenSearch options validations and Build the HttpClient.
|
25
25
|
# Note that this methods may sets the @user, @password, @hosts and @client ivars as a side effect.
|
26
26
|
# @return [HttpClient] the new http client
|
27
|
-
def build_client
|
28
|
-
|
27
|
+
def build_client
|
28
|
+
|
29
29
|
# the following 3 options validation & setup methods are called inside build_client
|
30
30
|
# because they must be executed prior to building the client and logstash
|
31
31
|
# monitoring and management rely on directly calling build_client
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-output-opensearch'
|
3
|
-
s.version = '1.
|
3
|
+
s.version = '1.1.0'
|
4
4
|
|
5
5
|
s.licenses = ['Apache-2.0']
|
6
6
|
s.summary = "Stores logs in OpenSearch"
|
@@ -18,6 +18,9 @@ Gem::Specification.new do |s|
|
|
18
18
|
# Tests
|
19
19
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
20
20
|
|
21
|
+
s.cert_chain = ['certs/opensearch-rubygems.pem']
|
22
|
+
s.signing_key = File.expand_path("private_key.pem") if $0 =~ /gem\z/
|
23
|
+
|
21
24
|
# Special flag to let us know this is actually a logstash plugin
|
22
25
|
s.metadata = {
|
23
26
|
"logstash_plugin" => "true",
|
@@ -25,9 +28,6 @@ Gem::Specification.new do |s|
|
|
25
28
|
"source_code_uri" => "https://github.com/opensearch-project/logstash-output-opensearch"
|
26
29
|
}
|
27
30
|
|
28
|
-
s.cert_chain = ['public.pem']
|
29
|
-
s.signing_key = File.expand_path("private.pem") if $0 =~ /gem\z/
|
30
|
-
|
31
31
|
s.add_runtime_dependency "manticore", '>= 0.5.4', '< 1.0.0'
|
32
32
|
s.add_runtime_dependency 'stud', ['>= 0.0.17', '~> 0.0']
|
33
33
|
s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
|
@@ -67,7 +67,7 @@ describe "indexing with http_compression turned on", :integration => true do
|
|
67
67
|
|
68
68
|
it "sets the correct content-encoding header and body is compressed" do
|
69
69
|
expect(subject.client.pool.adapter.client).to receive(:send).
|
70
|
-
with(anything, anything, {:headers=>{"Content-Encoding"=>"gzip", "
|
70
|
+
with(anything, anything, {:headers=>{"Content-Encoding"=>"gzip", "content-type"=>"application/json"}, :body => a_valid_gzip_encoded_string}).
|
71
71
|
and_call_original
|
72
72
|
subject.multi_receive(events)
|
73
73
|
end
|
@@ -95,10 +95,10 @@ describe "indexing" do
|
|
95
95
|
end
|
96
96
|
|
97
97
|
it "sets the correct content-type header" do
|
98
|
-
expected_manticore_opts = {:headers => {"
|
98
|
+
expected_manticore_opts = {:headers => {"content-type" => "application/json"}, :body => anything}
|
99
99
|
if secure
|
100
100
|
expected_manticore_opts = {
|
101
|
-
:headers => {"
|
101
|
+
:headers => {"content-type" => "application/json"},
|
102
102
|
:body => anything,
|
103
103
|
:auth => {
|
104
104
|
:user => user,
|
@@ -50,7 +50,7 @@ describe "Ingest pipeline execution behavior", :integration => true do
|
|
50
50
|
http_client.delete(ingest_url).call
|
51
51
|
|
52
52
|
# register pipeline
|
53
|
-
http_client.put(ingest_url, :body => apache_logs_pipeline, :headers => {"
|
53
|
+
http_client.put(ingest_url, :body => apache_logs_pipeline, :headers => {"content-type" => "application/json" }).call
|
54
54
|
|
55
55
|
#TODO: Use esclient
|
56
56
|
#@client.ingest.put_pipeline :id => 'apache_pipeline', :body => pipeline_defintion
|
@@ -25,7 +25,7 @@ context "join field tests", :integration => true do
|
|
25
25
|
let(:parent_relation) { "parent_type" }
|
26
26
|
let(:child_relation) { "child_type" }
|
27
27
|
let(:default_headers) {
|
28
|
-
{"
|
28
|
+
{"content-type" => "application/json"}
|
29
29
|
}
|
30
30
|
subject { LogStash::Outputs::OpenSearch.new(config) }
|
31
31
|
|
@@ -42,7 +42,7 @@ describe LogStash::Outputs::OpenSearch::HttpClient::ManticoreAdapter do
|
|
42
42
|
|
43
43
|
expect(subject.manticore).to receive(:get).
|
44
44
|
with(expected_uri.to_s, {
|
45
|
-
:headers => {"
|
45
|
+
:headers => {"content-type" => "application/json"},
|
46
46
|
:auth => {
|
47
47
|
:user => user,
|
48
48
|
:password => password,
|
@@ -16,8 +16,7 @@ describe LogStash::Outputs::OpenSearch::HttpClient::Pool do
|
|
16
16
|
let(:adapter) { LogStash::Outputs::OpenSearch::HttpClient::ManticoreAdapter.new(logger) }
|
17
17
|
let(:initial_urls) { [::LogStash::Util::SafeURI.new("http://localhost:9200")] }
|
18
18
|
let(:options) { {:resurrect_delay => 2, :url_normalizer => proc {|u| u}} } # Shorten the delay a bit to speed up tests
|
19
|
-
let(:node_versions) { [ "
|
20
|
-
let(:get_distribution) { "oss" }
|
19
|
+
let(:node_versions) { [ "0.0.0" ] }
|
21
20
|
|
22
21
|
subject { described_class.new(logger, adapter, initial_urls, options) }
|
23
22
|
|
@@ -32,7 +31,6 @@ describe LogStash::Outputs::OpenSearch::HttpClient::Pool do
|
|
32
31
|
allow(::Manticore::Client).to receive(:new).and_return(manticore_double)
|
33
32
|
|
34
33
|
allow(subject).to receive(:get_version).with(any_args).and_return(*node_versions)
|
35
|
-
allow(subject.distribution_checker).to receive(:get_distribution).and_return(get_distribution)
|
36
34
|
end
|
37
35
|
|
38
36
|
after do
|
@@ -212,94 +210,13 @@ describe LogStash::Outputs::OpenSearch::HttpClient::Pool do
|
|
212
210
|
end
|
213
211
|
|
214
212
|
it "picks the largest major version" do
|
215
|
-
expect(subject.maximum_seen_major_version).to eq(
|
213
|
+
expect(subject.maximum_seen_major_version).to eq(0)
|
216
214
|
end
|
217
215
|
|
218
216
|
context "if there are nodes with multiple major versions" do
|
219
|
-
let(:node_versions) { [ "0.0.0", "
|
217
|
+
let(:node_versions) { [ "0.0.0", "6.0.0" ] }
|
220
218
|
it "picks the largest major version" do
|
221
|
-
expect(subject.maximum_seen_major_version).to eq(
|
222
|
-
end
|
223
|
-
end
|
224
|
-
end
|
225
|
-
describe "distribution checking" do
|
226
|
-
before(:each) do
|
227
|
-
allow(subject).to receive(:health_check_request)
|
228
|
-
end
|
229
|
-
|
230
|
-
let(:options) do
|
231
|
-
super().merge(:distribution_checker => distribution_checker)
|
232
|
-
end
|
233
|
-
|
234
|
-
context 'when DistributionChecker#is_supported? returns false' do
|
235
|
-
let(:distribution_checker) { double('DistributionChecker', :is_supported? => false) }
|
236
|
-
|
237
|
-
it 'does not mark the URL as active' do
|
238
|
-
subject.update_initial_urls
|
239
|
-
expect(subject.alive_urls_count).to eq(0)
|
240
|
-
end
|
241
|
-
end
|
242
|
-
|
243
|
-
context 'when DistributionChecker#is_supported? returns true' do
|
244
|
-
let(:distribution_checker) { double('DistributionChecker', :is_supported? => true) }
|
245
|
-
|
246
|
-
it 'marks the URL as active' do
|
247
|
-
subject.update_initial_urls
|
248
|
-
expect(subject.alive_urls_count).to eq(1)
|
249
|
-
end
|
250
|
-
end
|
251
|
-
end
|
252
|
-
describe 'distribution checking with cluster output' do
|
253
|
-
let(:options) do
|
254
|
-
super().merge(:distribution_checker => LogStash::Outputs::OpenSearch::DistributionChecker.new(logger))
|
255
|
-
end
|
256
|
-
|
257
|
-
before(:each) do
|
258
|
-
allow(subject).to receive(:health_check_request)
|
259
|
-
end
|
260
|
-
|
261
|
-
context 'when using opensearch' do
|
262
|
-
|
263
|
-
context "if cluster doesn't return a valid distribution" do
|
264
|
-
let(:get_distribution) { nil }
|
265
|
-
|
266
|
-
it 'marks the url as dead' do
|
267
|
-
subject.update_initial_urls
|
268
|
-
expect(subject.alive_urls_count).to eq(0)
|
269
|
-
end
|
270
|
-
|
271
|
-
it 'logs message' do
|
272
|
-
expect(subject.distribution_checker).to receive(:log_not_supported).once.and_call_original
|
273
|
-
subject.update_initial_urls
|
274
|
-
end
|
275
|
-
end
|
276
|
-
|
277
|
-
context 'if cluster returns opensearch' do
|
278
|
-
let(:get_distribution) { 'opensearch' }
|
279
|
-
|
280
|
-
it "marks the url as active" do
|
281
|
-
subject.update_initial_urls
|
282
|
-
expect(subject.alive_urls_count).to eq(1)
|
283
|
-
end
|
284
|
-
|
285
|
-
it 'does not log message' do
|
286
|
-
expect(subject.distribution_checker).to_not receive(:log_not_supported)
|
287
|
-
subject.update_initial_urls
|
288
|
-
end
|
289
|
-
end
|
290
|
-
|
291
|
-
context 'if cluster returns oss' do
|
292
|
-
let(:get_distribution) { 'oss' }
|
293
|
-
|
294
|
-
it 'marks the url as active' do
|
295
|
-
subject.update_initial_urls
|
296
|
-
expect(subject.alive_urls_count).to eq(1)
|
297
|
-
end
|
298
|
-
|
299
|
-
it 'does not log message' do
|
300
|
-
expect(subject.distribution_checker).to_not receive(:log_not_supported)
|
301
|
-
subject.update_initial_urls
|
302
|
-
end
|
219
|
+
expect(subject.maximum_seen_major_version).to eq(6)
|
303
220
|
end
|
304
221
|
end
|
305
222
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-opensearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Elastic
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
yXikuH6LEVykA8pgOcB9gKsB2/zMd2ZlSj2monM8Qw9EfB14ZSDTYS8VYuwWCeF0
|
32
32
|
eFmXXk0ufQFKl1Yll7quHkmQ0PzKkvXTpONBT6qPkXE=
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2021-
|
34
|
+
date: 2021-09-21 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
requirement: !ruby/object:Gem::Requirement
|
@@ -173,6 +173,7 @@ extra_rdoc_files: []
|
|
173
173
|
files:
|
174
174
|
- ADMINS.md
|
175
175
|
- CODE_OF_CONDUCT.md
|
176
|
+
- COMPATIBILITY.md
|
176
177
|
- CONTRIBUTING.md
|
177
178
|
- DEVELOPER_GUIDE.md
|
178
179
|
- Gemfile
|
@@ -183,7 +184,6 @@ files:
|
|
183
184
|
- RELEASING.md
|
184
185
|
- SECURITY.md
|
185
186
|
- lib/logstash/outputs/opensearch.rb
|
186
|
-
- lib/logstash/outputs/opensearch/distribution_checker.rb
|
187
187
|
- lib/logstash/outputs/opensearch/http_client.rb
|
188
188
|
- lib/logstash/outputs/opensearch/http_client/manticore_adapter.rb
|
189
189
|
- lib/logstash/outputs/opensearch/http_client/pool.rb
|
@@ -193,7 +193,6 @@ files:
|
|
193
193
|
- lib/logstash/outputs/opensearch/templates/ecs-disabled/7x.json
|
194
194
|
- lib/logstash/plugin_mixins/opensearch/api_configs.rb
|
195
195
|
- lib/logstash/plugin_mixins/opensearch/common.rb
|
196
|
-
- lib/logstash/plugin_mixins/opensearch/noop_distribution_checker.rb
|
197
196
|
- logstash-output-opensearch.gemspec
|
198
197
|
- spec/fixtures/_nodes/nodes.json
|
199
198
|
- spec/fixtures/htpasswd
|
metadata.gz.sig
CHANGED
Binary file
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# SPDX-License-Identifier: Apache-2.0
|
2
|
-
#
|
3
|
-
# The OpenSearch Contributors require contributions made to
|
4
|
-
# this file be licensed under the Apache-2.0 license or a
|
5
|
-
# compatible open source license.
|
6
|
-
#
|
7
|
-
# Modifications Copyright OpenSearch Contributors. See
|
8
|
-
# GitHub history for details.
|
9
|
-
#
|
10
|
-
module LogStash; module Outputs; class OpenSearch
|
11
|
-
class DistributionChecker
|
12
|
-
|
13
|
-
def initialize(logger)
|
14
|
-
@logger = logger
|
15
|
-
end
|
16
|
-
|
17
|
-
# Checks whether connecting cluster is one of supported distribution or not
|
18
|
-
# @param pool
|
19
|
-
# @param url [LogStash::Util::SafeURI] OpenSearch node URL
|
20
|
-
# @param major_version OpenSearch major version number
|
21
|
-
# @return [Boolean] true if supported
|
22
|
-
def is_supported?(pool, url, major_version)
|
23
|
-
distribution = get_distribution(pool, url)
|
24
|
-
case distribution
|
25
|
-
when 'opensearch'
|
26
|
-
return true
|
27
|
-
when 'oss'
|
28
|
-
if major_version == 7
|
29
|
-
return true
|
30
|
-
end
|
31
|
-
end
|
32
|
-
log_not_supported(url, major_version, distribution)
|
33
|
-
false
|
34
|
-
end
|
35
|
-
|
36
|
-
def get_distribution(pool, url)
|
37
|
-
pool.get_distribution(url)
|
38
|
-
end
|
39
|
-
|
40
|
-
def log_not_supported(url, major_version, distribution)
|
41
|
-
@logger.error("Could not connect to cluster", url: url.sanitized.to_s, distribution: distribution, major_version: major_version)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end; end; end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# SPDX-License-Identifier: Apache-2.0
|
2
|
-
#
|
3
|
-
# The OpenSearch Contributors require contributions made to
|
4
|
-
# this file be licensed under the Apache-2.0 license or a
|
5
|
-
# compatible open source license.
|
6
|
-
#
|
7
|
-
# Modifications Copyright OpenSearch Contributors. See
|
8
|
-
# GitHub history for details.
|
9
|
-
|
10
|
-
module LogStash; module PluginMixins; module OpenSearch
|
11
|
-
class NoopDistributionChecker
|
12
|
-
INSTANCE = self.new
|
13
|
-
|
14
|
-
def is_supported?(pool, url, major_version)
|
15
|
-
true
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end; end; end
|