logstash-integration-elastic_enterprise_search 2.1.2 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -10
- data/DEVELOPER.md +2 -1
- data/lib/logstash/outputs/elastic_app_search.rb +36 -6
- data/logstash-integration-elastic_enterprise_search.gemspec +3 -1
- data/spec/integration/outputs/elastic_app_search_spec.rb +13 -13
- data/spec/integration/outputs/elastic_workplace_search_spec.rb +2 -2
- data/spec/unit/outputs/appsearch_spec.rb +14 -0
- metadata +31 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6276fe38b651d58dcfa68a99d6d6de58f4b7a35d4e5cf640f996cbd7b681a7ad
|
4
|
+
data.tar.gz: 373697b1c10c3c51af094d0415e407033ea1d987d776f4c0e0a83146b998f2cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 898a93fb3d0516b4b6f2a0eb358a29809e581a56ed7c5ca3be21e95f778dd4e63b81e615dbe9bfb96a22cc1439d3f840f0e574a4b56de4e08de3a5eff36ccce9
|
7
|
+
data.tar.gz: 9f4edd07607d41ee54ec36141dd0b009ae8eb5c24364b05a200b419e2efdd800ed57694f10c150e56c1186ee54639fff31361a6c72e9ecff44fb431f251c82b9
|
data/CHANGELOG.md
CHANGED
@@ -1,19 +1,24 @@
|
|
1
|
+
|
2
|
+
## 2.2.0
|
3
|
+
- Feature, switch the connection library to elastic-enterprise-search [#3](https://github.com/logstash-plugins/logstash-integration-elastic_enterprise_search/pull/3)
|
4
|
+
- [DOC] Added required parameters to Workplace Search example snippet and describe little better what's expected in url parameter [#11](https://github.com/logstash-plugins/logstash-integration-elastic_enterprise_search/pull/11)
|
5
|
+
|
1
6
|
## 2.1.2
|
2
|
-
- [DOC] Fix typos in App Search and Workplace Search [#9](https://github.com/logstash-plugins/logstash-integration-elastic_enterprise_search/pull/9)
|
3
|
-
- [DOC] Add links to Elastic App Search and Elastic Workplace Search solution pages [#10](https://github.com/logstash-plugins/logstash-integration-elastic_enterprise_search/pull/9)
|
7
|
+
- [DOC] Fix typos in App Search and Workplace Search [#9](https://github.com/logstash-plugins/logstash-integration-elastic_enterprise_search/pull/9)
|
8
|
+
- [DOC] Add links to Elastic App Search and Elastic Workplace Search solution pages [#10](https://github.com/logstash-plugins/logstash-integration-elastic_enterprise_search/pull/9)
|
4
9
|
|
5
10
|
## 2.1.1
|
6
|
-
- [DOC] Added the integration attribute and include statement for the integration plugin header to finalize hooking up integration docs [#8](https://github.com/logstash-plugins/logstash-integration-elastic_enterprise_search/pull/8)
|
7
|
-
- [DOC] Added live link to output-elastic_workplace_search doc [#6](https://github.com/logstash-plugins/logstash-integration-elastic_enterprise_search/pull/6)
|
11
|
+
- [DOC] Added the integration attribute and include statement for the integration plugin header to finalize hooking up integration docs [#8](https://github.com/logstash-plugins/logstash-integration-elastic_enterprise_search/pull/8)
|
12
|
+
- [DOC] Added live link to output-elastic_workplace_search doc [#6](https://github.com/logstash-plugins/logstash-integration-elastic_enterprise_search/pull/6)
|
8
13
|
|
9
14
|
## 2.1.0
|
10
|
-
- Addition of Workplace Search Output plugin [#4](https://github.com/logstash-plugins/logstash-integration-elastic_enterprise_search/pull/4)
|
11
|
-
- [DOC] Added the integration attribute and include statement for the integration plugin header to output-elastic_app_search doc [#5](https://github.com/logstash-plugins/logstash-integration-elastic_enterprise_search/pull/5)
|
15
|
+
- Addition of Workplace Search Output plugin [#4](https://github.com/logstash-plugins/logstash-integration-elastic_enterprise_search/pull/4)
|
16
|
+
- [DOC] Added the integration attribute and include statement for the integration plugin header to output-elastic_app_search doc [#5](https://github.com/logstash-plugins/logstash-integration-elastic_enterprise_search/pull/5)
|
12
17
|
|
13
18
|
|
14
19
|
## 2.0.0
|
15
|
-
- Initial release of the Elastic EnterpriseSearch Integration Plugin, which carries the
|
16
|
-
|
17
|
-
|
18
|
-
|
20
|
+
- Initial release of the Elastic EnterpriseSearch Integration Plugin, which carries the
|
21
|
+
previous AppSearch Output plugin codebase;
|
22
|
+
independent changelogs for previous versions can be found:
|
23
|
+
- [AppSearch Output Plugin @1.2.0](https://github.com/logstash-plugins/logstash-output-elastic_app_search/blob/v1.2.0/CHANGELOG.md)
|
19
24
|
|
data/DEVELOPER.md
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require "logstash/outputs/base"
|
3
3
|
require "elastic-app-search"
|
4
|
+
require "elastic-enterprise-search"
|
5
|
+
require 'logstash/plugin_mixins/deprecation_logger_support'
|
4
6
|
|
5
7
|
class LogStash::Outputs::ElasticAppSearch < LogStash::Outputs::Base
|
8
|
+
include LogStash::PluginMixins::DeprecationLoggerSupport
|
9
|
+
|
6
10
|
config_name "elastic_app_search"
|
7
11
|
|
8
12
|
# The name of the search engine you created in App Search, an information
|
@@ -49,16 +53,25 @@ class LogStash::Outputs::ElasticAppSearch < LogStash::Outputs::Base
|
|
49
53
|
|
50
54
|
public
|
51
55
|
def register
|
56
|
+
@use_old_client = false
|
52
57
|
if @host.nil? && @url.nil?
|
53
58
|
raise ::LogStash::ConfigurationError.new("Please specify either \"url\" (for self-managed) or \"host\" (for SaaS).")
|
54
59
|
elsif @host && @url
|
55
|
-
raise ::LogStash::ConfigurationError.new("Both \"url\" or \"host\" can't be set simultaneously. Please specify either \"url\" (for self-managed) or \"host\" (for SaaS).")
|
60
|
+
raise ::LogStash::ConfigurationError.new("Both \"url\" or \"host\" can't be set simultaneously. Please specify either \"url\" (for self-managed ot Elastic Enterprise Search) or \"host\" (for SaaS).")
|
56
61
|
elsif @host && path_is_set? # because path has a default value we need extra work to if the user set it
|
57
62
|
raise ::LogStash::ConfigurationError.new("The setting \"path\" is not compatible with \"host\". Use \"path\" only with \"url\".")
|
58
63
|
elsif @host
|
64
|
+
@deprecation_logger.deprecated("Deprecated service usage, the `host` setting will be removed when Swiftype AppSearch service is shutdown")
|
65
|
+
@use_old_client = true
|
59
66
|
@client = Elastic::AppSearch::Client.new(:host_identifier => @host, :api_key => @api_key.value)
|
60
67
|
elsif @url
|
61
|
-
|
68
|
+
if path_is_set?
|
69
|
+
@deprecation_logger.deprecated("Deprecated service usage, the `path` setting will be removed when Swiftype AppSearch service is shutdown")
|
70
|
+
@use_old_client = true
|
71
|
+
@client = Elastic::AppSearch::Client.new(:api_endpoint => @url + @path, :api_key => @api_key.value)
|
72
|
+
else
|
73
|
+
@client = Elastic::EnterpriseSearch::AppSearch::Client.new(:host => @url, :http_auth => @api_key.value, :external_url => @url)
|
74
|
+
end
|
62
75
|
end
|
63
76
|
check_connection! unless @engine =~ ENGINE_WITH_SPRINTF_REGEX
|
64
77
|
rescue => e
|
@@ -117,11 +130,15 @@ class LogStash::Outputs::ElasticAppSearch < LogStash::Outputs::Base
|
|
117
130
|
if resolved_engine =~ ENGINE_WITH_SPRINTF_REGEX || resolved_engine =~ /^\s*$/
|
118
131
|
raise "Cannot resolve engine field name #{@engine} from event"
|
119
132
|
end
|
120
|
-
|
133
|
+
if connected_to_swiftype?
|
134
|
+
response = @client.index_documents(resolved_engine, documents)
|
135
|
+
else
|
136
|
+
response = @client.index_documents(resolved_engine, {:documents => documents})
|
137
|
+
end
|
121
138
|
report(documents, response)
|
122
139
|
rescue => e
|
123
140
|
@logger.error("Failed to execute index operation. Retrying..", :exception => e.class, :reason => e.message,
|
124
|
-
:resolved_engine => resolved_engine)
|
141
|
+
:resolved_engine => resolved_engine, :backtrace => e.backtrace)
|
125
142
|
sleep(1)
|
126
143
|
retry
|
127
144
|
end
|
@@ -130,7 +147,11 @@ class LogStash::Outputs::ElasticAppSearch < LogStash::Outputs::Base
|
|
130
147
|
|
131
148
|
def report(documents, response)
|
132
149
|
documents.each_with_index do |document, i|
|
133
|
-
|
150
|
+
if connected_to_swiftype?
|
151
|
+
errors = response[i]["errors"]
|
152
|
+
else
|
153
|
+
errors = response.body[i]["errors"]
|
154
|
+
end
|
134
155
|
if errors.empty?
|
135
156
|
@logger.trace? && @logger.trace("Document was indexed with no errors", :document => document)
|
136
157
|
else
|
@@ -140,10 +161,19 @@ class LogStash::Outputs::ElasticAppSearch < LogStash::Outputs::Base
|
|
140
161
|
end
|
141
162
|
|
142
163
|
def check_connection!
|
143
|
-
|
164
|
+
if connected_to_swiftype?
|
165
|
+
@client.get_engine(@engine)
|
166
|
+
else
|
167
|
+
res = @client.list_engines({:page_size => 1})
|
168
|
+
raise "Received HTTP error code #{res.status}" unless res.status == 200
|
169
|
+
end
|
144
170
|
end
|
145
171
|
|
146
172
|
def path_is_set?
|
147
173
|
original_params.key?("path")
|
148
174
|
end
|
175
|
+
|
176
|
+
def connected_to_swiftype?
|
177
|
+
@use_old_client
|
178
|
+
end
|
149
179
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-integration-elastic_enterprise_search'
|
3
|
-
s.version = '2.
|
3
|
+
s.version = '2.2.0'
|
4
4
|
s.licenses = ['Apache-2.0']
|
5
5
|
s.summary = "Integration with Elastic Enterprise Search - output plugins"
|
6
6
|
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline "+
|
@@ -27,6 +27,8 @@ Gem::Specification.new do |s|
|
|
27
27
|
s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"
|
28
28
|
s.add_runtime_dependency "logstash-codec-plain"
|
29
29
|
s.add_runtime_dependency "elastic-app-search", '~>7.8.0'
|
30
|
+
s.add_runtime_dependency "elastic-enterprise-search", '~>7.16.0'
|
30
31
|
s.add_runtime_dependency "elastic-workplace-search", '~>0.4.1'
|
32
|
+
s.add_runtime_dependency "logstash-mixin-deprecation_logger_support", '~>1.0'
|
31
33
|
s.add_development_dependency "logstash-devutils"
|
32
34
|
end
|
@@ -13,16 +13,16 @@ describe "indexing against running App Search", :integration => true do
|
|
13
13
|
|
14
14
|
let(:config) do
|
15
15
|
{
|
16
|
-
"api_key" => ENV['
|
16
|
+
"api_key" => ENV['APP_SEARCH_PRIVATE_KEY'],
|
17
17
|
"engine" => engine_name,
|
18
|
-
"url" => "http://
|
18
|
+
"url" => "http://enterprise_search:3002"
|
19
19
|
}
|
20
20
|
end
|
21
21
|
|
22
22
|
subject(:app_search_output) { LogStash::Outputs::ElasticAppSearch.new(config) }
|
23
23
|
|
24
24
|
before(:each) do
|
25
|
-
create_engine(engine_name, "http://
|
25
|
+
create_engine(engine_name, "http://enterprise_search:3002", ENV['APP_SEARCH_PRIVATE_KEY'])
|
26
26
|
end
|
27
27
|
|
28
28
|
private
|
@@ -37,8 +37,8 @@ describe "indexing against running App Search", :integration => true do
|
|
37
37
|
describe "search and private keys are configured" do
|
38
38
|
let(:api_key_settings) do
|
39
39
|
{
|
40
|
-
:private => ENV['
|
41
|
-
:search => ENV['
|
40
|
+
:private => ENV['APP_SEARCH_PRIVATE_KEY'],
|
41
|
+
:search => ENV['APP_SEARCH_SEARCH_KEY']
|
42
42
|
}
|
43
43
|
end
|
44
44
|
|
@@ -51,9 +51,9 @@ describe "indexing against running App Search", :integration => true do
|
|
51
51
|
describe "register" do
|
52
52
|
let(:config) do
|
53
53
|
{
|
54
|
-
"api_key" => ENV['
|
54
|
+
"api_key" => ENV['APP_SEARCH_PRIVATE_KEY'],
|
55
55
|
"engine" => "%{engine_name_field}",
|
56
|
-
"url" => "http://
|
56
|
+
"url" => "http://enterprise_search:3002"
|
57
57
|
}
|
58
58
|
end
|
59
59
|
|
@@ -89,9 +89,9 @@ describe "indexing against running App Search", :integration => true do
|
|
89
89
|
context "using sprintf-ed engine" do
|
90
90
|
let(:config) do
|
91
91
|
{
|
92
|
-
"api_key" => ENV['
|
92
|
+
"api_key" => ENV['APP_SEARCH_PRIVATE_KEY'],
|
93
93
|
"engine" => "%{engine_name_field}",
|
94
|
-
"url" => "http://
|
94
|
+
"url" => "http://enterprise_search:3002"
|
95
95
|
}
|
96
96
|
end
|
97
97
|
|
@@ -134,15 +134,15 @@ describe "indexing against running App Search", :integration => true do
|
|
134
134
|
context "multiple sprintf engines" do
|
135
135
|
let(:config) do
|
136
136
|
{
|
137
|
-
"api_key" => ENV['
|
137
|
+
"api_key" => ENV['APP_SEARCH_PRIVATE_KEY'],
|
138
138
|
"engine" => "%{engine_name_field}",
|
139
|
-
"url" => "http://
|
139
|
+
"url" => "http://enterprise_search:3002"
|
140
140
|
}
|
141
141
|
end
|
142
142
|
|
143
143
|
it "all should be indexed" do
|
144
|
-
create_engine('testengin1', "http://
|
145
|
-
create_engine('testengin2', "http://
|
144
|
+
create_engine('testengin1', "http://enterprise_search:3002", ENV['APP_SEARCH_PRIVATE_KEY'])
|
145
|
+
create_engine('testengin2', "http://enterprise_search:3002", ENV['APP_SEARCH_PRIVATE_KEY'])
|
146
146
|
events = generate_events(100, 'testengin1')
|
147
147
|
events += generate_events(100, 'testengin2')
|
148
148
|
events.shuffle!
|
@@ -8,8 +8,8 @@ require "base64"
|
|
8
8
|
|
9
9
|
describe "indexing against running Workplace Search", :integration => true do
|
10
10
|
|
11
|
-
let(:url) { ENV['
|
12
|
-
let(:auth) { Base64.strict_encode64("#{ENV['
|
11
|
+
let(:url) { ENV['ENTERPRISE_SEARCH_URL'] }
|
12
|
+
let(:auth) { Base64.strict_encode64("#{ENV['ENTERPRISE_SEARCH_USERNAME']}:#{ENV['ENTERPRISE_SEARCH_PASSWORD']}")}
|
13
13
|
let(:source) do
|
14
14
|
response = Faraday.post(
|
15
15
|
"#{url}/ws/org/sources/form_create",
|
@@ -3,6 +3,7 @@ require "logstash/devutils/rspec/spec_helper"
|
|
3
3
|
require "logstash/outputs/elastic_app_search"
|
4
4
|
require "logstash/codecs/plain"
|
5
5
|
require "logstash/event"
|
6
|
+
require "elastic-app-search"
|
6
7
|
|
7
8
|
describe LogStash::Outputs::ElasticAppSearch do
|
8
9
|
let(:sample_event) { LogStash::Event.new }
|
@@ -20,6 +21,19 @@ describe LogStash::Outputs::ElasticAppSearch do
|
|
20
21
|
it "does not raise an error" do
|
21
22
|
expect { subject.register }.to_not raise_error
|
22
23
|
end
|
24
|
+
it "configures the Swiftype client" do
|
25
|
+
subject.register
|
26
|
+
client = subject.instance_variable_get(:@client)
|
27
|
+
expect(client.class).to eq(Elastic::AppSearch::Client)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
context "when path is configured" do
|
31
|
+
let(:config) { { "api_key" => api_key, "engine" => engine, "path" => "/v1", "url" => "http://localhost:9300" } }
|
32
|
+
it "configures the Swiftype client" do
|
33
|
+
subject.register
|
34
|
+
client = subject.instance_variable_get(:@client)
|
35
|
+
expect(client.class).to eq(Elastic::AppSearch::Client)
|
36
|
+
end
|
23
37
|
end
|
24
38
|
context "when host and path is configured" do
|
25
39
|
let(:config) { { "host" => host, "api_key" => api_key, "engine" => engine, "path" => "/v1" } }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-integration-elastic_enterprise_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 7.8.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 7.16.0
|
61
|
+
name: elastic-enterprise-search
|
62
|
+
prerelease: false
|
63
|
+
type: :runtime
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 7.16.0
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
requirement: !ruby/object:Gem::Requirement
|
57
71
|
requirements:
|
@@ -66,6 +80,20 @@ dependencies:
|
|
66
80
|
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: 0.4.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '1.0'
|
89
|
+
name: logstash-mixin-deprecation_logger_support
|
90
|
+
prerelease: false
|
91
|
+
type: :runtime
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.0'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
requirement: !ruby/object:Gem::Requirement
|
71
99
|
requirements:
|
@@ -124,8 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
152
|
- !ruby/object:Gem::Version
|
125
153
|
version: '0'
|
126
154
|
requirements: []
|
127
|
-
|
128
|
-
rubygems_version: 2.6.13
|
155
|
+
rubygems_version: 3.1.6
|
129
156
|
signing_key:
|
130
157
|
specification_version: 4
|
131
158
|
summary: Integration with Elastic Enterprise Search - output plugins
|