logstash-output-amazon_es 2.0.1-java → 6.4.0-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/CONTRIBUTORS +12 -0
- data/Gemfile +8 -0
- data/LICENSE +10 -199
- data/README.md +34 -65
- data/lib/logstash/outputs/amazon_es.rb +218 -423
- data/lib/logstash/outputs/amazon_es/common.rb +347 -0
- data/lib/logstash/outputs/amazon_es/common_configs.rb +141 -0
- data/lib/logstash/outputs/amazon_es/elasticsearch-template-es2x.json +95 -0
- data/lib/logstash/outputs/amazon_es/elasticsearch-template-es5x.json +46 -0
- data/lib/logstash/outputs/amazon_es/elasticsearch-template-es6x.json +45 -0
- data/lib/logstash/outputs/amazon_es/elasticsearch-template-es7x.json +46 -0
- data/lib/logstash/outputs/amazon_es/http_client.rb +359 -74
- data/lib/logstash/outputs/amazon_es/http_client/manticore_adapter.rb +169 -0
- data/lib/logstash/outputs/amazon_es/http_client/pool.rb +457 -0
- data/lib/logstash/outputs/amazon_es/http_client_builder.rb +164 -0
- data/lib/logstash/outputs/amazon_es/template_manager.rb +36 -0
- data/logstash-output-amazon_es.gemspec +13 -22
- data/spec/es_spec_helper.rb +37 -0
- data/spec/unit/http_client_builder_spec.rb +189 -0
- data/spec/unit/outputs/elasticsearch/http_client/manticore_adapter_spec.rb +105 -0
- data/spec/unit/outputs/elasticsearch/http_client/pool_spec.rb +198 -0
- data/spec/unit/outputs/elasticsearch/http_client_spec.rb +222 -0
- data/spec/unit/outputs/elasticsearch/template_manager_spec.rb +25 -0
- data/spec/unit/outputs/elasticsearch_spec.rb +615 -0
- data/spec/unit/outputs/error_whitelist_spec.rb +60 -0
- metadata +49 -110
- data/lib/logstash/outputs/amazon_es/aws_transport.rb +0 -109
- data/lib/logstash/outputs/amazon_es/aws_v4_signer.rb +0 -7
- data/lib/logstash/outputs/amazon_es/aws_v4_signer_impl.rb +0 -62
- data/lib/logstash/outputs/amazon_es/elasticsearch-template.json +0 -41
- data/spec/amazon_es_spec_helper.rb +0 -69
- data/spec/unit/outputs/amazon_es_spec.rb +0 -50
- data/spec/unit/outputs/elasticsearch/protocol_spec.rb +0 -36
- data/spec/unit/outputs/elasticsearch_proxy_spec.rb +0 -58
@@ -1,41 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"template" : "logstash-*",
|
3
|
-
"settings" : {
|
4
|
-
"index.refresh_interval" : "5s"
|
5
|
-
},
|
6
|
-
"mappings" : {
|
7
|
-
"_default_" : {
|
8
|
-
"_all" : {"enabled" : true, "omit_norms" : true},
|
9
|
-
"dynamic_templates" : [ {
|
10
|
-
"message_field" : {
|
11
|
-
"match" : "message",
|
12
|
-
"match_mapping_type" : "string",
|
13
|
-
"mapping" : {
|
14
|
-
"type" : "string", "index" : "analyzed", "omit_norms" : true
|
15
|
-
}
|
16
|
-
}
|
17
|
-
}, {
|
18
|
-
"string_fields" : {
|
19
|
-
"match" : "*",
|
20
|
-
"match_mapping_type" : "string",
|
21
|
-
"mapping" : {
|
22
|
-
"type" : "string", "index" : "analyzed", "omit_norms" : true,
|
23
|
-
"fields" : {
|
24
|
-
"raw" : {"type": "string", "index" : "not_analyzed", "ignore_above" : 256}
|
25
|
-
}
|
26
|
-
}
|
27
|
-
}
|
28
|
-
} ],
|
29
|
-
"properties" : {
|
30
|
-
"@version": { "type": "string", "index": "not_analyzed" },
|
31
|
-
"geoip" : {
|
32
|
-
"type" : "object",
|
33
|
-
"dynamic": true,
|
34
|
-
"properties" : {
|
35
|
-
"location" : { "type" : "geo_point" }
|
36
|
-
}
|
37
|
-
}
|
38
|
-
}
|
39
|
-
}
|
40
|
-
}
|
41
|
-
}
|
@@ -1,69 +0,0 @@
|
|
1
|
-
require "logstash/devutils/rspec/spec_helper"
|
2
|
-
require "ftw"
|
3
|
-
require "logstash/plugin"
|
4
|
-
require "logstash/json"
|
5
|
-
require "stud/try"
|
6
|
-
require "longshoreman"
|
7
|
-
|
8
|
-
CONTAINER_NAME = "logstash-output-amazon-es-#{rand(999).to_s}"
|
9
|
-
CONTAINER_IMAGE = "elasticsearch"
|
10
|
-
CONTAINER_TAG = "1.6"
|
11
|
-
|
12
|
-
DOCKER_INTEGRATION = ENV["DOCKER_INTEGRATION"]
|
13
|
-
|
14
|
-
module ESHelper
|
15
|
-
def get_host
|
16
|
-
DOCKER_INTEGRATION ? Longshoreman.new.get_host_ip : "127.0.0.1"
|
17
|
-
end
|
18
|
-
|
19
|
-
def get_port
|
20
|
-
return 9200 unless DOCKER_INTEGRATION
|
21
|
-
|
22
|
-
container = Longshoreman::Container.new
|
23
|
-
container.get(CONTAINER_NAME)
|
24
|
-
container.rport(9200)
|
25
|
-
end
|
26
|
-
|
27
|
-
def get_client
|
28
|
-
Elasticsearch::Client.new(:host => "#{get_host}:#{get_port}")
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
|
33
|
-
RSpec.configure do |config|
|
34
|
-
config.include ESHelper
|
35
|
-
|
36
|
-
|
37
|
-
if DOCKER_INTEGRATION
|
38
|
-
# this :all hook gets run before every describe block that is tagged with :integration => true.
|
39
|
-
config.before(:all, :integration => true) do
|
40
|
-
|
41
|
-
|
42
|
-
# check if container exists already before creating new one.
|
43
|
-
begin
|
44
|
-
ls = Longshoreman::new
|
45
|
-
ls.container.get(CONTAINER_NAME)
|
46
|
-
rescue Docker::Error::NotFoundError
|
47
|
-
Longshoreman.new("#{CONTAINER_IMAGE}:#{CONTAINER_TAG}", CONTAINER_NAME)
|
48
|
-
# TODO(talevy): verify ES is running instead of static timeout
|
49
|
-
sleep 10
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
# we want to do a final cleanup after all :integration runs,
|
54
|
-
# but we don't want to clean up before the last block.
|
55
|
-
# This is a final blind check to see if the ES docker container is running and
|
56
|
-
# needs to be cleaned up. If no container can be found and/or docker is not
|
57
|
-
# running on the system, we do nothing.
|
58
|
-
config.after(:suite) do
|
59
|
-
# only cleanup docker container if system has docker and the container is running
|
60
|
-
begin
|
61
|
-
ls = Longshoreman::new
|
62
|
-
ls.container.get(CONTAINER_NAME)
|
63
|
-
ls.cleanup
|
64
|
-
rescue Docker::Error::NotFoundError, Excon::Errors::SocketError
|
65
|
-
# do nothing
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
require_relative "../../../spec/amazon_es_spec_helper"
|
2
|
-
|
3
|
-
describe "outputs/amazon_es" do
|
4
|
-
describe "http client create" do
|
5
|
-
require "logstash/outputs/amazon_es"
|
6
|
-
require "elasticsearch"
|
7
|
-
|
8
|
-
let(:options) {
|
9
|
-
{
|
10
|
-
"index" => "my-index",
|
11
|
-
"hosts" => "localhost",
|
12
|
-
"path" => "some-path"
|
13
|
-
}
|
14
|
-
}
|
15
|
-
|
16
|
-
let(:eso) {LogStash::Outputs::AmazonES.new(options)}
|
17
|
-
|
18
|
-
let(:manticore_host) {
|
19
|
-
eso.client.send(:client).transport.options[:hosts].first
|
20
|
-
}
|
21
|
-
|
22
|
-
around(:each) do |block|
|
23
|
-
thread = eso.register
|
24
|
-
block.call()
|
25
|
-
thread.kill()
|
26
|
-
end
|
27
|
-
|
28
|
-
describe "with path" do
|
29
|
-
it "should properly create a URI with the path" do
|
30
|
-
expect(eso.path).to eql(options["path"])
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
it "should properly set the path on the HTTP client" do
|
35
|
-
expect(manticore_host).to include("/" + options["path"])
|
36
|
-
end
|
37
|
-
|
38
|
-
context "with extra slashes" do
|
39
|
-
let(:path) { "/slashed-path/ "}
|
40
|
-
let(:eso) {
|
41
|
-
LogStash::Outputs::AmazonES.new(options.merge("path" => "/some-path/"))
|
42
|
-
}
|
43
|
-
|
44
|
-
it "should properly set the path on the HTTP client without adding slashes" do
|
45
|
-
expect(manticore_host).to include(options["path"])
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require "logstash/devutils/rspec/spec_helper"
|
2
|
-
require "logstash/outputs/amazon_es/http_client"
|
3
|
-
require "java"
|
4
|
-
|
5
|
-
describe LogStash::Outputs::AES::HttpClient do
|
6
|
-
context "successful" do
|
7
|
-
it "should map correctly" do
|
8
|
-
bulk_response = {"took"=>74, "errors"=>false, "items"=>[{"create"=>{"_index"=>"logstash-2014.11.17",
|
9
|
-
"_type"=>"logs", "_id"=>"AUxTS2C55Jrgi-hC6rQF",
|
10
|
-
"_version"=>1, "status"=>201}}]}
|
11
|
-
actual = LogStash::Outputs::AES::HttpClient.normalize_bulk_response(bulk_response)
|
12
|
-
insist { actual } == {"errors"=> false}
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
context "contains failures" do
|
17
|
-
it "should map correctly" do
|
18
|
-
bulk_response = {"took"=>71, "errors"=>true,
|
19
|
-
"items"=>[{"create"=>{"_index"=>"logstash-2014.11.17",
|
20
|
-
"_type"=>"logs", "_id"=>"AUxTQ_OI5Jrgi-hC6rQB", "status"=>400,
|
21
|
-
"error"=>"MapperParsingException[failed to parse]..."}}]}
|
22
|
-
actual = LogStash::Outputs::AES::HttpClient.normalize_bulk_response(bulk_response)
|
23
|
-
insist { actual } == {"errors"=> true, "statuses"=> [400]}
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "sniffing" do
|
28
|
-
let(:base_options) { {:hosts => ["127.0.0.1"] }}
|
29
|
-
let(:client) { LogStash::Outputs::AES::HttpClient.new(base_options.merge(client_opts)) }
|
30
|
-
let(:transport) { client.client.transport }
|
31
|
-
|
32
|
-
before do
|
33
|
-
allow(transport).to receive(:reload_connections!)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
require_relative "../../../spec/amazon_es_spec_helper"
|
2
|
-
require 'stud/temporary'
|
3
|
-
require 'elasticsearch'
|
4
|
-
require "logstash/outputs/amazon_es"
|
5
|
-
|
6
|
-
describe "Proxy option" do
|
7
|
-
let(:settings) {
|
8
|
-
{
|
9
|
-
"hosts" => "node01",
|
10
|
-
"proxy" => proxy
|
11
|
-
}
|
12
|
-
}
|
13
|
-
subject {
|
14
|
-
LogStash::Outputs::AmazonES.new(settings)
|
15
|
-
}
|
16
|
-
|
17
|
-
before do
|
18
|
-
allow(::Elasticsearch::Client).to receive(:new).with(any_args)
|
19
|
-
end
|
20
|
-
|
21
|
-
describe "valid configs" do
|
22
|
-
before do
|
23
|
-
subject.register
|
24
|
-
end
|
25
|
-
|
26
|
-
context "when specified as a string" do
|
27
|
-
let(:proxy) { "http://127.0.0.1:1234" }
|
28
|
-
|
29
|
-
it "should set the proxy to the exact value" do
|
30
|
-
expect(::Elasticsearch::Client).to have_received(:new) do |options|
|
31
|
-
expect(options[:transport_options][:proxy]).to eql(proxy)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context "when specified as a hash" do
|
37
|
-
let(:proxy) { {"hosts" => "127.0.0.1", "protocol" => "http"} }
|
38
|
-
|
39
|
-
it "should pass through the proxy values as symbols" do
|
40
|
-
expected = {:hosts => proxy["hosts"], :protocol => proxy["protocol"]}
|
41
|
-
expect(::Elasticsearch::Client).to have_received(:new) do |options|
|
42
|
-
expect(options[:transport_options][:proxy]).to eql(expected)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe "invalid configs" do
|
49
|
-
let(:proxy) { ["bad", "stuff"] }
|
50
|
-
|
51
|
-
it "should have raised an exception" do
|
52
|
-
expect {
|
53
|
-
subject.register
|
54
|
-
}.to raise_error(LogStash::ConfigurationError)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|