fluent-plugin-aws-elasticsearch-service 0.1.0
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 +7 -0
- data/.gitignore +35 -0
- data/Gemfile +8 -0
- data/LICENSE +22 -0
- data/README.md +58 -0
- data/Rakefile +10 -0
- data/fluent-plugin-aws-elasticsearch-service.gemspec +30 -0
- data/lib/fluent/plugin/out_aws-elasticsearch-service.rb +122 -0
- metadata +149 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7e67fc954f730743d5a89c67f29a060e92764498
|
4
|
+
data.tar.gz: 7beb32b73861d1ca4614ae303026ad311c6baddf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bfbb04a89975ba7c06b515a2b1b9d4357eac2ab6c4512d7d44af0d7cda00b8680d3d346c29a4414cbe3f9b948609940b99b24cf0369c5718d19e58f5fe3cf3ee
|
7
|
+
data.tar.gz: 070a07ea3bb3589fee8d8b5f359e53774557ac5849e869b9454dbcb418c976eee54cce1721a92ac79d2eb4ca7a47d90850bdc11c9ac7811ab76538205f550c33
|
data/.gitignore
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/vendor/bundle
|
26
|
+
/lib/bundler/man/
|
27
|
+
|
28
|
+
# for a library or gem, you might want to ignore these files since the code is
|
29
|
+
# intended to run in multiple environments; otherwise, check them in:
|
30
|
+
# Gemfile.lock
|
31
|
+
# .ruby-version
|
32
|
+
# .ruby-gemset
|
33
|
+
|
34
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
35
|
+
.rvmrc
|
data/Gemfile
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in fluent-plugin-aws-elasticsearch-service.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
gem 'fluent-plugin-elasticsearch', '~> 1.0', require: false
|
7
|
+
gem 'aws-sdk', '~> 2', require: false
|
8
|
+
gem 'faraday_middleware-aws-signers-v4', require: false
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 @
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# Fluent::AwsElasticsearchServiceOutput
|
2
|
+
|
3
|
+
This output plugin to post to "Amazon Elasticsearch Service".
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'fluent-plugin-aws-elasticsearch-service'
|
11
|
+
```
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
In your fluentd configration, use `type aws-elasticsearch-service`.
|
16
|
+
|
17
|
+
example:
|
18
|
+
|
19
|
+
```rb
|
20
|
+
source do
|
21
|
+
type :tail
|
22
|
+
format :apache
|
23
|
+
time_format "%d/%b/%Y:%T %z"
|
24
|
+
path "/var/log/nginx/access.log"
|
25
|
+
pos_file "/var/log/td-agent/nginx.access.pos"
|
26
|
+
tag "es.nginx.access"
|
27
|
+
end
|
28
|
+
|
29
|
+
match ("es.**") do
|
30
|
+
type "aws-elasticsearch-service"
|
31
|
+
type_name "access_log"
|
32
|
+
logstash_format true
|
33
|
+
include_tag_key true
|
34
|
+
tag_key "@log_name"
|
35
|
+
flush_interval "10s"
|
36
|
+
|
37
|
+
endpoint do
|
38
|
+
url "YOUR_ENDPOINT_URL"
|
39
|
+
region "ap-northeast-1"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
```
|
43
|
+
|
44
|
+
## Development
|
45
|
+
|
46
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
47
|
+
|
48
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
49
|
+
|
50
|
+
## Contributing
|
51
|
+
|
52
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/atomita/fluent-plugin-aws-elasticsearch-service. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
53
|
+
|
54
|
+
|
55
|
+
## License
|
56
|
+
|
57
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
58
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "fluent-plugin-aws-elasticsearch-service"
|
8
|
+
spec.version = "0.1.0"
|
9
|
+
spec.authors = ["atomita"]
|
10
|
+
spec.email = ["sleeping.cait.sith+gh@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Output plugin to post to "Amazon Elasticsearch Service".}
|
13
|
+
spec.description = %q{this is a Output plugin. Post to "Amazon Elasticsearch Service".}
|
14
|
+
spec.homepage = "https://github.com/atomita/fluent-plugin-aws-elasticsearch-service"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
26
|
+
spec.add_runtime_dependency "fluentd", "~> 0"
|
27
|
+
spec.add_runtime_dependency "fluent-plugin-elasticsearch", "~> 1.0"
|
28
|
+
spec.add_runtime_dependency "aws-sdk", "~> 2"
|
29
|
+
spec.add_runtime_dependency "faraday_middleware-aws-signers-v4", "~> 0"
|
30
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'fluent/plugin/out_elasticsearch'
|
5
|
+
require 'aws-sdk'
|
6
|
+
require 'faraday_middleware'
|
7
|
+
require 'faraday_middleware/aws_signers_v4'
|
8
|
+
|
9
|
+
|
10
|
+
module Fluent
|
11
|
+
class AwsElasticsearchServiceOutput < ElasticsearchOutput
|
12
|
+
|
13
|
+
Plugin.register_output('aws-elasticsearch-service', self)
|
14
|
+
|
15
|
+
config_section :endpoint do
|
16
|
+
config_param :region, :string
|
17
|
+
config_param :url, :string
|
18
|
+
config_param :access_key_id, :string, :default => ""
|
19
|
+
config_param :secret_access_key, :string, :default => ""
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
#
|
24
|
+
# @override
|
25
|
+
#
|
26
|
+
def get_connection_options
|
27
|
+
raise "`endpoint` require." if @endpoint.empty?
|
28
|
+
|
29
|
+
hosts =
|
30
|
+
begin
|
31
|
+
@endpoint.map do |ep|
|
32
|
+
uri = URI(ep[:url])
|
33
|
+
host = %w(user password path).inject(host: uri.host, port: uri.port, scheme: uri.scheme) do |hash, key|
|
34
|
+
hash[key.to_sym] = uri.public_send(key) unless uri.public_send(key).nil? || uri.public_send(key) == ''
|
35
|
+
hash
|
36
|
+
end
|
37
|
+
|
38
|
+
host[:aws_elasticsearch_service] = {
|
39
|
+
:credentials => credentials(ep[:access_key_id], ep[:secret_access_key]),
|
40
|
+
:region => ep[:region]
|
41
|
+
}
|
42
|
+
|
43
|
+
host
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
{
|
48
|
+
hosts: hosts
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
#
|
56
|
+
# get AWS Credentials
|
57
|
+
#
|
58
|
+
def credentials(access_key, secret_key)
|
59
|
+
@credentials ||= {}
|
60
|
+
@credentials[access_key] ||= {}
|
61
|
+
@credentials[access_key][secret_key] ||=
|
62
|
+
begin
|
63
|
+
credentials = nil
|
64
|
+
if access_key.empty? or secret_key.empty?
|
65
|
+
credentials = Aws::InstanceProfileCredentials.new.credentials
|
66
|
+
credentials ||= Aws::SharedCredentials.new.credentials
|
67
|
+
end
|
68
|
+
credentials ||= Aws::Credentials.new access_key, secret_key
|
69
|
+
credentials
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
#
|
75
|
+
# monkey patch
|
76
|
+
#
|
77
|
+
class ElasticsearchOutput::Elasticsearch::Transport::Transport::HTTP::Faraday
|
78
|
+
|
79
|
+
alias :__build_connections_origin_from_aws_elasticsearch_service_output :__build_connections
|
80
|
+
|
81
|
+
# Builds and returns a collection of connections.
|
82
|
+
#
|
83
|
+
# @return [Connections::Collection]
|
84
|
+
# @override
|
85
|
+
#
|
86
|
+
def __build_connections
|
87
|
+
Elasticsearch::Transport::Transport::Connections::Collection.new(
|
88
|
+
:connections => hosts.map { |host|
|
89
|
+
host[:protocol] = host[:scheme] || DEFAULT_PROTOCOL
|
90
|
+
host[:port] ||= DEFAULT_PORT
|
91
|
+
url = __full_url(host)
|
92
|
+
|
93
|
+
Elasticsearch::Transport::Transport::Connections::Connection.new(
|
94
|
+
:host => host,
|
95
|
+
:connection => ::Faraday::Connection.new(
|
96
|
+
url,
|
97
|
+
(options[:transport_options] || {}),
|
98
|
+
&__aws_elasticsearch_service_setting(host, &@block)
|
99
|
+
),
|
100
|
+
:options => host[:connection_options]
|
101
|
+
)
|
102
|
+
},
|
103
|
+
:selector_class => options[:selector_class],
|
104
|
+
:selector => options[:selector]
|
105
|
+
)
|
106
|
+
end
|
107
|
+
|
108
|
+
def __aws_elasticsearch_service_setting(host, &block)
|
109
|
+
lambda do |faraday|
|
110
|
+
if host[:aws_elasticsearch_service]
|
111
|
+
faraday.request :aws_signers_v4,
|
112
|
+
credentials: host[:aws_elasticsearch_service][:credentials],
|
113
|
+
service_name: 'es',
|
114
|
+
region: host[:aws_elasticsearch_service][:region]
|
115
|
+
end
|
116
|
+
block.call faraday
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
end
|
metadata
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-aws-elasticsearch-service
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- atomita
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: fluentd
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: fluent-plugin-elasticsearch
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: aws-sdk
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: faraday_middleware-aws-signers-v4
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: this is a Output plugin. Post to "Amazon Elasticsearch Service".
|
112
|
+
email:
|
113
|
+
- sleeping.cait.sith+gh@gmail.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- Gemfile
|
120
|
+
- LICENSE
|
121
|
+
- README.md
|
122
|
+
- Rakefile
|
123
|
+
- fluent-plugin-aws-elasticsearch-service.gemspec
|
124
|
+
- lib/fluent/plugin/out_aws-elasticsearch-service.rb
|
125
|
+
homepage: https://github.com/atomita/fluent-plugin-aws-elasticsearch-service
|
126
|
+
licenses:
|
127
|
+
- MIT
|
128
|
+
metadata: {}
|
129
|
+
post_install_message:
|
130
|
+
rdoc_options: []
|
131
|
+
require_paths:
|
132
|
+
- lib
|
133
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
requirements: []
|
144
|
+
rubyforge_project:
|
145
|
+
rubygems_version: 2.2.2
|
146
|
+
signing_key:
|
147
|
+
specification_version: 4
|
148
|
+
summary: Output plugin to post to "Amazon Elasticsearch Service".
|
149
|
+
test_files: []
|