logstash-mixin-http_client 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3be85aa47707c0efff5108ef847692de49ff1c2b
4
+ data.tar.gz: 84c250cb85d7af53eff7c3e98c68ed0583b4e4be
5
+ SHA512:
6
+ metadata.gz: ad251e9bd636dda5e6f6914967a2f965d183cb5aca111428d0cc6c5e3319e3a7d1fcbb4558ec687034a44fe7aa132dab2f8442babf740252a742a83b835727a9
7
+ data.tar.gz: bb7c09d980bdf6dca16a3527184f679784aa6481099d9ff5ccce4f2d2a66de620636765e2222d3d8ae6a5cc3ce8b0d2358a4a12ff99876d5ae1da46ebacfed84
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ *.gem
2
+ Gemfile.lock
3
+ .bundle
4
+ vendor
5
+ .idea
6
+ *~
data/CHANGELOG.md ADDED
@@ -0,0 +1,2 @@
1
+ # 1.0.0
2
+ * Allow to use either V1 or V2 of the `AWS-SDK` in your plugins. Fixes: https://github.com/logstash-plugins/logstash-mixin-aws/issues/8
data/CONTRIBUTORS ADDED
@@ -0,0 +1,10 @@
1
+ The following is a list of people who have contributed ideas, code, bug
2
+ reports, or in general have helped logstash along its way.
3
+
4
+ Contributors:
5
+ * Andrew Cholakian (andrewvc)
6
+
7
+ Note: If you've sent us patches, bug reports, or otherwise contributed to
8
+ Logstash, and you aren't on the list above and want to be, please let us know
9
+ and we'll make sure you're here. Contributions from folks like you are what make
10
+ open source awesome.
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2012–2015 Elasticsearch <http://www.elastic.co>
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,131 @@
1
+ # Usage
2
+
3
+ This is a plugin for [Logstash](https://github.com/elasticsearch/logstash).
4
+
5
+ It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
6
+
7
+ This plugin exposes the following options:
8
+
9
+ ```ruby
10
+ # Timeout (in seconds) for the entire request
11
+ request_timeout, :validate => :number, :default => 60
12
+
13
+ # Timeout (in seconds) to wait for data on the socket. Default is 10s
14
+ config :socket_timeout, :validate => :number, :default => 10
15
+
16
+ # Timeout (in seconds) to wait for a connection to be established. Default is 10s
17
+ config :connect_timeout, :validate => :number, :default => 10
18
+
19
+ # Should redirects be followed? Defaults to true
20
+ config :follow_redirects, :validate => :boolean, :default => true
21
+
22
+ # Max number of concurrent connections. Defaults to 50
23
+ config :pool_max, :validate => :number, :default => 50
24
+
25
+ # Max number of concurrent connections to a single host. Defaults to 25
26
+ config :pool_max_per_route, :validate => :number, :default => 25
27
+
28
+ # How many times should the client retry a failing URL? Default is 3
29
+ config :automatic_retries, :validate => :number, :default => 3
30
+
31
+ # If you need to use a custom X.509 CA (.pem certs) specify the path to that here
32
+ config :ca_path, :validate => :path
33
+
34
+ # If you need to use a custom keystore (.jks) specify that here
35
+ config :truststore_path, :validate => :path
36
+
37
+ # Specify the keystore password here.
38
+ # Note, most .jks files created with keytool require a password!
39
+ config :truststore_password, :validate => :string
40
+
41
+ # Enable cookie support. With this enabled the client will persist cookies
42
+ # across requests as a normal web browser would. Enabled by default
43
+ config :cookies, :validate => :boolean, :default => true
44
+
45
+ # If you'd like to use an HTTP proxy . This supports multiple configuration syntaxes:
46
+ # 1. Proxy host in form: http://proxy.org:1234
47
+ # 2. Proxy host in form: {host => "proxy.org", port => 80, scheme => 'http', user => 'username@host', password => 'password'}
48
+ # 3. Proxy host in form: {url => 'http://proxy.org:1234', user => 'username@host', password => 'password'}
49
+ config :proxy
50
+ ```
51
+
52
+ ## Documentation
53
+
54
+ Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elasticsearch.org/guide/en/logstash/current/).
55
+
56
+ - For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
57
+ - For more asciidoc formatting tips, see the excellent reference here https://github.com/elasticsearch/docs#asciidoc-guide
58
+
59
+ ## Need Help?
60
+
61
+ Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
62
+
63
+ ## Developing
64
+
65
+ ### 1. Plugin Developement and Testing
66
+
67
+ #### Code
68
+ - To get started, you'll need JRuby with the Bundler gem installed.
69
+
70
+ - Create a new plugin or clone and existing from the GitHub [logstash-plugins](https://github.com/logstash-plugins) organization. We also provide [example plugins](https://github.com/logstash-plugins?query=example).
71
+
72
+ - Install dependencies
73
+ ```sh
74
+ bundle install
75
+ ```
76
+
77
+ #### Test
78
+
79
+ - Update your dependencies
80
+
81
+ ```sh
82
+ bundle install
83
+ ```
84
+
85
+ - Run tests
86
+
87
+ ```sh
88
+ bundle exec rspec
89
+ ```
90
+
91
+ ### 2. Running your unpublished Plugin in Logstash
92
+
93
+ #### 2.1 Run in a local Logstash clone
94
+
95
+ - Edit Logstash `Gemfile` and add the local plugin path, for example:
96
+ ```ruby
97
+ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
98
+ ```
99
+ - Install plugin
100
+ ```sh
101
+ bin/plugin install --no-verify
102
+ ```
103
+ - Run Logstash with your plugin
104
+ ```sh
105
+ bin/logstash -e 'filter {awesome {}}'
106
+ ```
107
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
108
+
109
+ #### 2.2 Run in an installed Logstash
110
+
111
+ You can use the same **2.1** method to run your plugin in an installed Logstash by editing its `Gemfile` and pointing the `:path` to your local plugin development directory or you can build the gem and install it using:
112
+
113
+ - Build your plugin gem
114
+ ```sh
115
+ gem build logstash-filter-awesome.gemspec
116
+ ```
117
+ - Install the plugin from the Logstash home
118
+ ```sh
119
+ bin/plugin install /your/local/plugin/logstash-filter-awesome.gem
120
+ ```
121
+ - Start Logstash and proceed to test the plugin
122
+
123
+ ## Contributing
124
+
125
+ All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
126
+
127
+ Programming is not a required skill. Whatever you've seen about open source and maintainers or community members saying "send patches or die" - you will not see that here.
128
+
129
+ It is more important to the community that you are able to contribute.
130
+
131
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elasticsearch/logstash/blob/master/CONTRIBUTING.md) file.
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ @files=[]
2
+
3
+ task :default do
4
+ system("rake -T")
5
+ end
6
+
7
+ require "logstash/devutils/rake"
@@ -0,0 +1,105 @@
1
+ # encoding: utf-8
2
+ require "logstash/config/mixin"
3
+
4
+ # This module provides helper for the `AWS-SDK` v1,
5
+ # and it will be deprecated in the near future, please use the V2 module
6
+ # for any new development.
7
+ module LogStash::PluginMixins::HttpClient
8
+ def self.included(base)
9
+ require 'manticore'
10
+ base.extend(self)
11
+ base.setup_http_client_config
12
+ end
13
+
14
+ public
15
+ def setup_http_client_config
16
+ # Timeout (in seconds) for the entire request
17
+ config :request_timeout, :validate => :number, :default => 60
18
+
19
+ # Timeout (in seconds) to wait for data on the socket. Default is 10s
20
+ config :socket_timeout, :validate => :number, :default => 10
21
+
22
+ # Timeout (in seconds) to wait for a connection to be established. Default is 10s
23
+ config :connect_timeout, :validate => :number, :default => 10
24
+
25
+ # Should redirects be followed? Defaults to true
26
+ config :follow_redirects, :validate => :boolean, :default => true
27
+
28
+ # Max number of concurrent connections. Defaults to 50
29
+ config :pool_max, :validate => :number, :default => 50
30
+
31
+ # Max number of concurrent connections to a single host. Defaults to 25
32
+ config :pool_max_per_route, :validate => :number, :default => 25
33
+
34
+ # How many times should the client retry a failing URL? Default is 3
35
+ config :automatic_retries, :validate => :number, :default => 3
36
+
37
+ # If you need to use a custom X.509 CA (.pem certs) specify the path to that here
38
+ config :ca_path, :validate => :path
39
+
40
+ # If you need to use a custom keystore (.jks) specify that here
41
+ config :truststore_path, :validate => :path
42
+
43
+ # Specify the keystore password here.
44
+ # Note, most .jks files created with keytool require a password!
45
+ config :truststore_password, :validate => :string
46
+
47
+ # Enable cookie support. With this enabled the client will persist cookies
48
+ # across requests as a normal web browser would. Enabled by default
49
+ config :cookies, :validate => :boolean, :default => true
50
+
51
+ # If you'd like to use an HTTP proxy . This supports multiple configuration syntaxes:
52
+ # 1. Proxy host in form: http://proxy.org:1234
53
+ # 2. Proxy host in form: {host => "proxy.org", port => 80, scheme => 'http', user => 'username@host', password => 'password'}
54
+ # 3. Proxy host in form: {url => 'http://proxy.org:1234', user => 'username@host', password => 'password'}
55
+ config :proxy
56
+ end
57
+
58
+ public
59
+ def client_config
60
+ c = {
61
+ connect_timeout: @connect_timeout,
62
+ socket_timeout: @socket_timeout,
63
+ request_timeout: @request_timeout,
64
+ follow_redirects: @follow_redirects,
65
+ automatic_retries: @automatic_retries,
66
+ pool_max: @pool_max,
67
+ pool_max_per_route: @pool_max_per_route,
68
+ cookies: @cookies,
69
+ }
70
+
71
+ if @proxy
72
+ # Symbolize keys if necessary
73
+ c[:proxy] = @proxy.is_a?(Hash) ?
74
+ @proxy.reduce({}) {|memo,(k,v)| memo[k.to_sym] = v; memo} :
75
+ @proxy
76
+ end
77
+
78
+ c[:ssl] = {}
79
+ if @ca_path
80
+ c[:ssl][:ca_file] = @ca_path
81
+ end
82
+ if (@truststore_path)
83
+ c[:ssl].merge!(
84
+ truststore: @truststore_path
85
+ )
86
+
87
+ # JKS files have optional passwords if programatically created
88
+ if (@truststore_password)
89
+ c[:ssl].merge!(truststore_password: @truststore_password)
90
+ end
91
+ end
92
+
93
+ c
94
+ end
95
+
96
+ private
97
+ def make_client
98
+ Manticore::Client.new(client_config)
99
+ end
100
+
101
+ public
102
+ def client
103
+ @client ||= make_client
104
+ end
105
+ end
@@ -0,0 +1,25 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'logstash-mixin-http_client'
3
+ s.version = '0.0.1'
4
+ s.licenses = ['Apache License (2.0)']
5
+ s.summary = "AWS mixins to provide a unified interface for Amazon Webservice"
6
+ s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
7
+ s.authors = ["Elastic"]
8
+ s.email = 'info@elastic.co'
9
+ s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
10
+ s.require_paths = ["lib"]
11
+
12
+ # Files
13
+ s.files = `git ls-files`.split($\)+::Dir.glob('vendor/*')
14
+
15
+ # Tests
16
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
17
+
18
+ # Gem dependencies
19
+ s.add_runtime_dependency "logstash-core", '>= 1.4.0', '< 2.0.0'
20
+ s.add_runtime_dependency 'logstash-codec-plain'
21
+ s.add_runtime_dependency 'manticore', '>= 0.4.1'
22
+
23
+ s.add_development_dependency 'logstash-devutils'
24
+ s.add_development_dependency 'stud'
25
+ end
@@ -0,0 +1,57 @@
1
+ # encoding: utf-8
2
+ require "logstash/devutils/rspec/spec_helper"
3
+ require "logstash/plugin_mixins/http_client"
4
+ require "stud/temporary"
5
+
6
+ class Dummy < LogStash::Inputs::Base
7
+ include LogStash::PluginMixins::HttpClient
8
+ end
9
+
10
+ describe LogStash::PluginMixins::HttpClient do
11
+ let(:basic_config) { {} }
12
+ let(:impl) { Dummy.new(basic_config) }
13
+
14
+ it "should initialize with no extra settings" do
15
+ expect {
16
+ impl
17
+ }.not_to raise_error
18
+ end
19
+
20
+ it "should create a client with defaults" do
21
+ expect(impl.send(:make_client)).to be_a(Manticore::Client)
22
+ end
23
+
24
+ it "#client should return the client" do
25
+ expect(impl.client).to be_a(Manticore::Client)
26
+ end
27
+
28
+ it "#client should return the same client" do
29
+ expect(impl.client).to eql(impl.client)
30
+ end
31
+
32
+ shared_examples "setting ca bundles" do |key|
33
+ subject { Dummy.new(conf).client_config }
34
+
35
+ it "should correctly set the path" do
36
+ expect(subject[:ssl][key]).to eql(path)
37
+ end
38
+ end
39
+
40
+ describe "with a custom ssl bundle" do
41
+ let(:file) { Stud::Temporary.file }
42
+ let(:path) { file.path }
43
+ after { File.unlink(path)}
44
+
45
+ context "with x509" do
46
+ let(:conf) { basic_config.merge("ca_path" => path) }
47
+
48
+ include_examples("setting ca bundles", :ca_file)
49
+ end
50
+
51
+ context "with JKS" do
52
+ let(:conf) { basic_config.merge("truststore_path" => path) }
53
+
54
+ include_examples("setting ca bundles", :truststore)
55
+ end
56
+ end
57
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-mixin-http_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Elastic
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: logstash-core
15
+ version_requirements: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.4.0
20
+ - - <
21
+ - !ruby/object:Gem::Version
22
+ version: 2.0.0
23
+ requirement: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - '>='
26
+ - !ruby/object:Gem::Version
27
+ version: 1.4.0
28
+ - - <
29
+ - !ruby/object:Gem::Version
30
+ version: 2.0.0
31
+ prerelease: false
32
+ type: :runtime
33
+ - !ruby/object:Gem::Dependency
34
+ name: logstash-codec-plain
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirement: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ prerelease: false
46
+ type: :runtime
47
+ - !ruby/object:Gem::Dependency
48
+ name: manticore
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 0.4.1
54
+ requirement: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - '>='
57
+ - !ruby/object:Gem::Version
58
+ version: 0.4.1
59
+ prerelease: false
60
+ type: :runtime
61
+ - !ruby/object:Gem::Dependency
62
+ name: logstash-devutils
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirement: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ prerelease: false
74
+ type: :development
75
+ - !ruby/object:Gem::Dependency
76
+ name: stud
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirement: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ prerelease: false
88
+ type: :development
89
+ description: This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program
90
+ email: info@elastic.co
91
+ executables: []
92
+ extensions: []
93
+ extra_rdoc_files: []
94
+ files:
95
+ - .gitignore
96
+ - CHANGELOG.md
97
+ - CONTRIBUTORS
98
+ - Gemfile
99
+ - LICENSE
100
+ - README.md
101
+ - Rakefile
102
+ - lib/logstash/plugin_mixins/http_client.rb
103
+ - logstash-mixin-http_client.gemspec
104
+ - spec/plugin_mixin/http_client_spec.rb
105
+ homepage: http://www.elastic.co/guide/en/logstash/current/index.html
106
+ licenses:
107
+ - Apache License (2.0)
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.1.9
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: AWS mixins to provide a unified interface for Amazon Webservice
129
+ test_files:
130
+ - spec/plugin_mixin/http_client_spec.rb