fluent-plugin-vmware-log-intelligence 2.0.5 → 2.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fda3fc2dd74d505b8554a65f96cba15afe0a188485fe04546da4b0c0ff686df4
4
- data.tar.gz: b1f298d59fd07a1e4dbdaf6de30e213efd1e9e8ce75589e7de40388880168bc2
3
+ metadata.gz: b02a27878c1270123d2ff6496ba8623d560046b4eaf9008e754ffd539e730765
4
+ data.tar.gz: c4350681f8298633c2dccca64ab783923e43feac26d5b00e2110d9f70eae088e
5
5
  SHA512:
6
- metadata.gz: b10231dc99aa642d6667fab12befc712a3552aaa6e0c4cadef3b0449df0bfe014683ecf3146b99fc5d1bd854b925c3d677046e990fca0809bb0db2416cb1919c
7
- data.tar.gz: c8391559359760faec9bf61b4dc3f900415c2c822151953727202e58093394283ca44f00e5c268d7a750b0c549d0cb14f31db7ee153a7b1b2d13af9d475b3a1b
6
+ metadata.gz: f683c0d3e06cd4d780cfcc72698a43dbb9d20c8f29c82b5b49e2478fd0779e57f5f810c2c89ea7c6f567d04196b3cab4d7a05ffc56915f2677c64117af37aba6
7
+ data.tar.gz: edb4eaca17536dbbf1cb545013921805a197635221c526c55fd2f98ab3d7c941ea1c763723c0dc5d60b4fb648a9029978b2dbce3906c7e6db7854f4cf31214f8
data/Gemfile CHANGED
@@ -1,11 +1,11 @@
1
- # Copyright (c) 2013 ablagoev
2
- # Copyright 2018 VMware, Inc.
3
- # SPDX-License-Identifier: MIT
4
-
5
- source "http://rubygems.org"
6
-
7
- gemspec
8
-
9
- group :test do
10
- gem 'coveralls', require: false
1
+ # Copyright (c) 2013 ablagoev
2
+ # Copyright 2018 VMware, Inc.
3
+ # SPDX-License-Identifier: MIT
4
+
5
+ source "http://rubygems.org"
6
+
7
+ gemspec
8
+
9
+ group :test do
10
+ gem 'coveralls', require: false
11
11
  end
@@ -1,15 +1,15 @@
1
- fluent-plugin-vmware-log-intelligence
2
-
3
- Copyright (c) 2013 ablagoev
4
- Copyright (c) 2018 VMware, Inc.
5
-
6
- The MIT license (the "License") set forth below applies to all parts of the fluent-plugin-vmware-log-intelligence project. You may not use this file except in compliance with the License.
7
-
8
- MIT License
9
-
10
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do
11
- so, subject to the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ fluent-plugin-vmware-log-intelligence
2
+
3
+ Copyright (c) 2013 ablagoev
4
+ Copyright (c) 2018 VMware, Inc.
5
+
6
+ The MIT license (the "License") set forth below applies to all parts of the fluent-plugin-vmware-log-intelligence project. You may not use this file except in compliance with the License.
7
+
8
+ MIT License
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do
11
+ so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,106 +1,113 @@
1
- = Overview
2
-
3
- vmware_log_intelligence is a Fluentd output plugin that buffers data and sends the data to VMware Log Intelligence.
4
-
5
- == Requirements
6
-
7
- fluentd version: 0.14.0 or above
8
-
9
- Ruby version: 2.2 or above
10
-
11
- == Build and install the plugin
12
-
13
- `gem build fluent-plugin-vmware-log-intelligence.gemspec`
14
-
15
- `gem install fluent-plugin-vmware-log-intelligence-1.0.0.gem`
16
-
17
- == Usage
18
- vmware_log_intelligence does not support Fluentd v0.12 style configurations.
19
- Please use Fluentd v1.0 style configurations when working with the plugin.
20
-
21
- Here is an example of the vmware_log_intelligence plugin configurations:
22
-
23
- <match pattern>
24
- @type vmware_log_intelligence
25
- endpoint_url https://data.upgrade.symphony-dev.com/le-mans/v1/streams/ingestion-pipeline-stream
26
- verify_ssl false
27
- <headers>
28
- Content-Type application/json
29
- Authorization Bearer Your-VMware-Log-Intelligence-API-Token
30
- structure simple
31
- </headers>
32
- <buffer>
33
- chunk_limit_records 300
34
- flush_interval 3s
35
- retry_max_times 3
36
- </buffer>
37
- <format>
38
- @type json
39
- tag_key text
40
- </format>
41
- </match>
42
-
43
- You can find more configuration examples in the files under the examples folder.
44
-
45
- Besides Fluentd, you can also use the plugin with td-agent.
46
-
47
- == Payload format
48
- VMware Log Intelligence expects the body of the HTTP requests you send to be in JSON format. It also expects the JSON payload to have a 'text' field that contains your raw log text.
49
-
50
- The fluentd way of turning raw log text into a JSON is to use the JSON formatter plugin (https://docs.fluentd.org/v0.12/articles/formatter_json). The plugin uses a 'tag' field to store the text of a log. One configuration option of the JSON formatter plugin is called 'tag_key'. You need to set 'tag_key' to 'text' so that the JSON formatter will generate JSON payloads that conform to what VMware Log Intelligence expects.
51
-
52
- == Configuration
53
-
54
- === endpoint_url
55
- This is the URL to which you want to send the logs to. You should set it to the URL of VMware Log Intelligence:
56
- https://data.upgrade.symphony-dev.com/le-mans/v1/streams/ingestion-pipeline-stream
57
-
58
- === verify_ssl
59
- You can use this setting to control whether the vmware_log_intelligence plugin should verify
60
- the SSL certificate of the endpoint_url. You should always set this to `true` except in testing
61
- or troubleshooting.
62
-
63
- === <headers>
64
- In order to send logs to VMware Log Intelligence, you need to have the `<headers>`
65
- section in your configuration. The `<headers>` section should look like the following:
66
-
67
- <headers>
68
- Content-Type application/json
69
- Authorization Bearer Your-VMware-Log-Intelligence-API-Token
70
- structure simple
71
- </headers>
72
-
73
- === <buffer>
74
- The vmware_log_intelligence plugin supports buffering. All the buffering configurations
75
- of Fluentd are supported. Detailed information of the buffering configurations can be
76
- found here https://docs.fluentd.org/v1.0/articles/buffer-section.
77
-
78
- == Run tests
79
- If you would like to contribute to this project, you might want to be able to run the tests
80
- under the `test` folder. You can do that in a Ruby environment you have set up on your dev
81
- machine. You can also run the tests in a Docker container. To run the tests in a Docker container,
82
- you can follow these steps:
83
-
84
- Go to the root folder of this project and build the Docker image like this:
85
- `docker build -t fluent-plugin-dev .`
86
-
87
- Run the container like this:
88
- `docker run --rm -i -t --name fluent-plugin-dev -v $(pwd):/app fluent-plugin-dev /bin/bash`
89
-
90
- Once inside the container, you can run the following to make sure that all dependecies are installed:
91
- `bundle install`
92
-
93
- Then you can run tests like this:
94
- `bundle exec rake`
95
-
96
- == Contributing
97
- The vmware_log_intelligence plugin project team welcomes contributions from the community. Before you start working with fluent-plugin-vmware-log-intelligence, please read our [Developer Certificate of Origin](https://cla.vmware.com/dco). All contributions to this repository must be signed as described on that page. Your signature certifies that you wrote the patch or have the right to pass it on as an open-source patch. For more detailed information, refer to [CONTRIBUTING.md](CONTRIBUTING.md).
98
-
99
- == License
100
- Please see LICENSE.txt[LICENSE.txt].
101
-
102
- == Copyright
103
-
104
- Copyright (c) 2013 ablagoev.
105
-
106
- Copyright 2018 VMware, Inc.
1
+ = Overview
2
+
3
+ vmware_log_intelligence is a Fluentd output plugin that buffers data and sends the data to VMware Log Intelligence.
4
+
5
+ == Requirements
6
+
7
+ fluentd version: 0.14.0 or above
8
+
9
+ Ruby version: 2.2 or above
10
+
11
+ == Build and install the plugin
12
+
13
+ `gem build fluent-plugin-vmware-log-intelligence.gemspec`
14
+
15
+ `gem install fluent-plugin-vmware-log-intelligence-1.0.0.gem`
16
+
17
+ == Usage
18
+ vmware_log_intelligence does not support Fluentd v0.12 style configurations.
19
+ Please use Fluentd v1.0 style configurations when working with the plugin.
20
+
21
+ Here is an example of the vmware_log_intelligence plugin configurations:
22
+
23
+ <match pattern>
24
+ @type vmware_log_intelligence
25
+ endpoint_url https://data.upgrade.symphony-dev.com/le-mans/v1/streams/ingestion-pipeline-stream
26
+ verify_ssl false
27
+ http_compress false
28
+ <headers>
29
+ Content-Type application/json
30
+ Authorization Bearer Your-VMware-Log-Intelligence-API-Token
31
+ structure simple
32
+ </headers>
33
+ <buffer>
34
+ @type file
35
+ path /path/to/buffer/lint.buf
36
+ chunk_limit_records 300
37
+ flush_interval 20s
38
+ delayed_commit_timeout 120s
39
+ retry_max_times 3
40
+ </buffer>
41
+ <format>
42
+ @type json
43
+ tag_key text
44
+ </format>
45
+ </match>
46
+
47
+ You can find more configuration examples in the files under the examples folder.
48
+
49
+ Besides Fluentd, you can also use the plugin with td-agent.
50
+
51
+ == Payload format
52
+ VMware Log Intelligence expects the body of the HTTP requests you send to be in JSON format. It also expects the JSON payload to have a 'text' field that contains your raw log text.
53
+
54
+ The fluentd way of turning raw log text into a JSON is to use the JSON formatter plugin (https://docs.fluentd.org/v0.12/articles/formatter_json). The plugin uses a 'tag' field to store the text of a log. One configuration option of the JSON formatter plugin is called 'tag_key'. You need to set 'tag_key' to 'text' so that the JSON formatter will generate JSON payloads that conform to what VMware Log Intelligence expects.
55
+
56
+ == Configuration
57
+
58
+ === endpoint_url
59
+ This is the URL to which you want to send the logs to. You should set it to the URL of VMware Log Intelligence:
60
+ https://data.upgrade.symphony-dev.com/le-mans/v1/streams/ingestion-pipeline-stream
61
+
62
+ === verify_ssl
63
+ You can use this setting to control whether the vmware_log_intelligence plugin should verify
64
+ the SSL certificate of the endpoint_url. You should always set this to `true` except in testing
65
+ or troubleshooting.
66
+
67
+ === http_compress
68
+ You can use this setting to compress the data while sending it to vRealize Log Insight Cloud. The default value is set 'false' here, If needed you can set it 'true'.
69
+
70
+ === <headers>
71
+ In order to send logs to VMware Log Intelligence, you need to have the `<headers>`
72
+ section in your configuration. The `<headers>` section should look like the following:
73
+
74
+ <headers>
75
+ Content-Type application/json
76
+ Authorization Bearer Your-VMware-Log-Intelligence-API-Token
77
+ structure simple
78
+ </headers>
79
+
80
+ === <buffer>
81
+ The vmware_log_intelligence plugin supports buffering. All the buffering configurations
82
+ of Fluentd are supported. Detailed information of the buffering configurations can be
83
+ found here https://docs.fluentd.org/v1.0/articles/buffer-section.
84
+
85
+ == Run tests
86
+ If you would like to contribute to this project, you might want to be able to run the tests
87
+ under the `test` folder. You can do that in a Ruby environment you have set up on your dev
88
+ machine. You can also run the tests in a Docker container. To run the tests in a Docker container,
89
+ you can follow these steps:
90
+
91
+ Go to the root folder of this project and build the Docker image like this:
92
+ `docker build -t fluent-plugin-dev .`
93
+
94
+ Run the container like this:
95
+ `docker run --rm -i -t --name fluent-plugin-dev -v $(pwd):/app fluent-plugin-dev /bin/bash`
96
+
97
+ Once inside the container, you can run the following to make sure that all dependecies are installed:
98
+ `bundle install`
99
+
100
+ Then you can run tests like this:
101
+ `bundle exec rake`
102
+
103
+ == Contributing
104
+ The vmware_log_intelligence plugin project team welcomes contributions from the community. Before you start working with fluent-plugin-vmware-log-intelligence, please read our [Developer Certificate of Origin](https://cla.vmware.com/dco). All contributions to this repository must be signed as described on that page. Your signature certifies that you wrote the patch or have the right to pass it on as an open-source patch. For more detailed information, refer to [CONTRIBUTING.md](CONTRIBUTING.md).
105
+
106
+ == License
107
+ Please see LICENSE.txt[LICENSE.txt].
108
+
109
+ == Copyright
110
+
111
+ Copyright (c) 2013 ablagoev.
112
+
113
+ Copyright 2018 VMware, Inc.
data/Rakefile CHANGED
@@ -1,16 +1,16 @@
1
- #!/usr/bin/env rake
2
-
3
- # Copyright (c) 2013 ablagoev
4
- # Copyright 2018 VMware, Inc.
5
- # SPDX-License-Identifier: MIT
6
-
7
- require "bundler/gem_tasks"
8
- require 'rake/testtask'
9
-
10
- Rake::TestTask.new(:test) do |test|
11
- test.libs << 'lib' << 'test'
12
- test.pattern = 'test/**/test_*.rb'
13
- test.verbose = true
14
- end
15
-
1
+ #!/usr/bin/env rake
2
+
3
+ # Copyright (c) 2013 ablagoev
4
+ # Copyright 2018 VMware, Inc.
5
+ # SPDX-License-Identifier: MIT
6
+
7
+ require "bundler/gem_tasks"
8
+ require 'rake/testtask'
9
+
10
+ Rake::TestTask.new(:test) do |test|
11
+ test.libs << 'lib' << 'test'
12
+ test.pattern = 'test/**/test_*.rb'
13
+ test.verbose = true
14
+ end
15
+
16
16
  task :default => :test
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.5
1
+ 2.0.6
@@ -1,53 +1,53 @@
1
- # Copyright (c) 2013 ablagoev
2
- # Copyright 2018 VMware, Inc.
3
- # SPDX-License-Identifier: MIT
4
-
5
- $:.push File.expand_path('../lib', __FILE__)
6
-
7
- Gem::Specification.new do |s|
8
- s.name = 'fluent-plugin-vmware-log-intelligence'
9
- s.version = File.read("VERSION").strip
10
- s.date = '2018-08-12'
11
- s.summary = "Fluentd buffered output plugin for VMware Log Intelligence"
12
- s.description = "Send Fluentd buffered logs to VMware Log Intelligence"
13
- s.authors = ["Alexander Blagoev", "Chaur Wu"]
14
- s.email = 'gwu@vmware.com'
15
- s.homepage =
16
- 'http://github.com/vmware/fluent-plugin-vmware-log-intelligence'
17
-
18
- s.files = [
19
- "lib/fluent/plugin/out_vmware_log_intelligence.rb",
20
- "lib/fluent/plugin/http_client.rb",
21
- "Gemfile",
22
- "LICENSE.txt",
23
- "README.rdoc",
24
- "Rakefile",
25
- "VERSION",
26
- "fluent-plugin-vmware-log-intelligence.gemspec",
27
- "test/helper.rb",
28
- "test/plugin/test_out_vmware_log_intelligence.rb",
29
- "test/plugin/test_http_client.rb",
30
- ]
31
-
32
- s.extra_rdoc_files = [
33
- "LICENSE.txt",
34
- "README.rdoc"
35
- ]
36
- s.licenses = ["MIT"]
37
-
38
- s.require_paths = ['lib']
39
-
40
- s.add_dependency "fluentd", ">= 0.14.20"
41
- s.add_dependency "http", ">= 0.9.8"
42
- s.add_dependency "myslog", "~> 0.0"
43
- s.add_dependency "fluent-plugin-mysqlslowquery", ">= 0.0.9"
44
- s.add_development_dependency "rake", ">= 0.9.2"
45
- s.add_development_dependency "bundler", ">= 1.3.4"
46
- s.add_development_dependency 'test-unit', '~> 3.1.0'
47
- s.add_development_dependency 'webmock', '~> 3.4.0'
48
- s.add_development_dependency 'fluent-plugin-detect-exceptions', '>= 0.0.12'
49
- s.add_development_dependency 'fluent-plugin-concat', '>= 2.0.0'
50
- s.add_development_dependency 'fluent-plugin-kubernetes_metadata_filter', '>= 2.0.0'
51
- s.add_development_dependency 'fluent-plugin-multi-format-parser', '>= 1.0.0'
52
- s.add_development_dependency 'fluent-plugin-postgres', '>= 0.0.1'
53
- end
1
+ # Copyright (c) 2013 ablagoev
2
+ # Copyright 2018 VMware, Inc.
3
+ # SPDX-License-Identifier: MIT
4
+
5
+ $:.push File.expand_path('../lib', __FILE__)
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = 'fluent-plugin-vmware-log-intelligence'
9
+ s.version = File.read("VERSION").strip
10
+ s.date = '2018-08-12'
11
+ s.summary = "Fluentd buffered output plugin for VMware Log Intelligence"
12
+ s.description = "Send Fluentd buffered logs to VMware Log Intelligence"
13
+ s.authors = ["Alexander Blagoev", "Chaur Wu"]
14
+ s.email = 'gwu@vmware.com'
15
+ s.homepage =
16
+ 'http://github.com/vmware/fluent-plugin-vmware-log-intelligence'
17
+
18
+ s.files = [
19
+ "lib/fluent/plugin/out_vmware_log_intelligence.rb",
20
+ "lib/fluent/plugin/http_client.rb",
21
+ "Gemfile",
22
+ "LICENSE.txt",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "fluent-plugin-vmware-log-intelligence.gemspec",
27
+ "test/helper.rb",
28
+ "test/plugin/test_out_vmware_log_intelligence.rb",
29
+ "test/plugin/test_http_client.rb",
30
+ ]
31
+
32
+ s.extra_rdoc_files = [
33
+ "LICENSE.txt",
34
+ "README.rdoc"
35
+ ]
36
+ s.licenses = ["MIT"]
37
+
38
+ s.require_paths = ['lib']
39
+
40
+ s.add_dependency "fluentd", ">= 0.14.20"
41
+ s.add_dependency "http", ">= 0.9.8"
42
+ s.add_dependency "myslog", "~> 0.0"
43
+ s.add_dependency "fluent-plugin-mysqlslowquery", ">= 0.0.9"
44
+ s.add_development_dependency "rake", ">= 0.9.2"
45
+ s.add_development_dependency "bundler", ">= 1.3.4"
46
+ s.add_development_dependency 'test-unit', '~> 3.1.0'
47
+ s.add_development_dependency 'webmock', '~> 3.4.0'
48
+ s.add_development_dependency 'fluent-plugin-detect-exceptions', '>= 0.0.12'
49
+ s.add_development_dependency 'fluent-plugin-concat', '>= 2.0.0'
50
+ s.add_development_dependency 'fluent-plugin-kubernetes_metadata_filter', '>= 2.0.0'
51
+ s.add_development_dependency 'fluent-plugin-multi-format-parser', '>= 1.0.0'
52
+ s.add_development_dependency 'fluent-plugin-postgres', '>= 0.0.1'
53
+ end
@@ -1,72 +1,72 @@
1
- # Copyright 2018 VMware, Inc.
2
- # SPDX-License-Identifier: MIT
3
-
4
- module Fluent::Plugin
5
- class HttpClient
6
- def initialize(endpoint_url, verify_ssl,
7
- headers, statuses, open_timeout, read_timeout, log)
8
- @log = log
9
- @statuses = statuses
10
- @options = {}
11
-
12
- if !verify_ssl
13
- @log.warn('SSL verification of the remote VMware Log Intelligence service is turned off. This is serious security risk. Please turn on SSL verification and restart the Fluentd/td-agent process.')
14
- ctx = OpenSSL::SSL::SSLContext.new
15
- ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE
16
- @options = {:ssl_context => ctx}
17
- end
18
-
19
- timeout_options = {
20
- :connect_timeout => open_timeout,
21
- :read_timeout => read_timeout
22
- }
23
-
24
- @conn = HTTP.persistent(endpoint_url)
25
- .headers(headers)
26
- .timeout(timeout_options)
27
-
28
- @endpoint_path = HTTP::URI.parse(endpoint_url).path
29
- @last_429_time = nil
30
- end
31
-
32
- def check_quota
33
- if @last_429_time
34
- if (Time.new - @last_429_time) < 600
35
- return false
36
- end
37
-
38
- @last_429_time = nil
39
- end
40
- return true
41
- end
42
-
43
- def post(data)
44
- if !check_quota
45
- return
46
- end
47
-
48
- begin
49
- response = @conn.post(@endpoint_path, @options.merge(:body => data))
50
- response.body.to_s
51
- if (response.code == 429)
52
- @log.warn('1GB quota of free account has been reached. Will stop sending data for 1 hour.')
53
- @last_429_time = Time.new
54
- else
55
- @last_429_time = nil
56
- end
57
-
58
- if @statuses.include? response.code.to_i
59
- # Raise an exception so that fluent will retry based on the configurations.
60
- fail "Server returned bad status: #{response.code}. #{response.to_s}"
61
- end
62
-
63
- rescue EOFError, SystemCallError, OpenSSL::SSL::SSLError => e
64
- @log.warn "http post raises exception: #{e.class}, '#{e.message}'"
65
- end
66
- end
67
-
68
- def close
69
- @conn.close
70
- end
71
- end
72
- end
1
+ # Copyright 2018 VMware, Inc.
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ module Fluent::Plugin
5
+ class HttpClient
6
+ def initialize(endpoint_url, verify_ssl,
7
+ headers, statuses, open_timeout, read_timeout, log)
8
+ @log = log
9
+ @statuses = statuses
10
+ @options = {}
11
+
12
+ if !verify_ssl
13
+ @log.warn('SSL verification of the remote VMware Log Intelligence service is turned off. This is serious security risk. Please turn on SSL verification and restart the Fluentd/td-agent process.')
14
+ ctx = OpenSSL::SSL::SSLContext.new
15
+ ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE
16
+ @options = {:ssl_context => ctx}
17
+ end
18
+
19
+ timeout_options = {
20
+ :connect_timeout => open_timeout,
21
+ :read_timeout => read_timeout
22
+ }
23
+
24
+ @conn = HTTP.persistent(endpoint_url)
25
+ .headers(headers)
26
+ .timeout(timeout_options)
27
+
28
+ @endpoint_path = HTTP::URI.parse(endpoint_url).path
29
+ @last_429_time = nil
30
+ end
31
+
32
+ def check_quota
33
+ if @last_429_time
34
+ if (Time.new - @last_429_time) < 600
35
+ return false
36
+ end
37
+
38
+ @last_429_time = nil
39
+ end
40
+ return true
41
+ end
42
+
43
+ def post(data)
44
+ if !check_quota
45
+ return
46
+ end
47
+
48
+ begin
49
+ response = @conn.post(@endpoint_path, @options.merge(:body => data))
50
+ response.body.to_s
51
+ if (response.code == 429)
52
+ @log.warn('1GB quota of free account has been reached. Will stop sending data for 1 hour.')
53
+ @last_429_time = Time.new
54
+ else
55
+ @last_429_time = nil
56
+ end
57
+
58
+ if @statuses.include? response.code.to_i
59
+ # Raise an exception so that fluent will retry based on the configurations.
60
+ fail "Server returned bad status: #{response.code}. #{response.to_s}"
61
+ end
62
+
63
+ rescue EOFError, SystemCallError, OpenSSL::SSL::SSLError => e
64
+ @log.warn "http post raises exception: #{e.class}, '#{e.message}'"
65
+ end
66
+ end
67
+
68
+ def close
69
+ @conn.close
70
+ end
71
+ end
72
+ end