fluent-plugin-logzio-ng 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c55028d4250990554c9e49ab43e06066060455d5
4
+ data.tar.gz: 3abde2e8d8eb74d19b3b60c757e4dca8be781276
5
+ SHA512:
6
+ metadata.gz: 8e32bcc693d18686019bbabc52c0133cecdaeef632bcc40afbbf24ca9368a8049afd641cbf913ad808e8c5090d694144b9959955cf6bba79375c61475cd0e5fc
7
+ data.tar.gz: a70a3d30682748e7ba7bd770a32b5ac3d60e12237a0b41fbbef17ce69335be63cec6ac6cab458f90611120abbda45317467846383e64d9374110c7613436378e
@@ -0,0 +1,35 @@
1
+ ### Ruby ###
2
+ *.gem
3
+ *.rbc
4
+ .config
5
+ coverage/
6
+ InstalledFiles
7
+ pkg/
8
+ spec/reports/
9
+ spec/examples.txt
10
+ test/tmp/
11
+ test/version_tmp/
12
+ tmp/
13
+
14
+ # Used by dotenv library to load environment variables.
15
+ # .env
16
+
17
+ ## Documentation cache and generated files:
18
+ .yardoc/
19
+ _yardoc/
20
+ doc/
21
+ rdoc/
22
+
23
+ ## Environment normalization:
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/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,4 @@
1
+ # 0.0.7
2
+
3
+ - Forked fluentd-plugin-logzio as it seems to be unsupported
4
+ -
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fluent-plugin-logzio-ng.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,42 @@
1
+ [![Gem Version](https://badge.fury.io/rb/fluent-plugin-logzio-ng.svg)](https://badge.fury.io/rb/fluent-plugin-logzio-ng)
2
+
3
+ Logz.io plugin for [Fluentd](http://www.fluentd.org)
4
+ =============
5
+ With fluent-plugin-logzio-ng you will be able to use [Logz.io](http://logz.io) as output the logs you collect with Fluentd.
6
+
7
+ ## Getting Started
8
+ * Install [Fluentd](http://www.fluentd.org/download)
9
+ * `gem install fluent-plugin-logzio-ng`
10
+ * Make sure you have an account with Logz.io.
11
+ * Configure Fluentd as below:
12
+ * It's recommended to set flush_interval to 2-3s.
13
+ * because after 5 second logz.io close TCP connection
14
+ * so TCP connections aren't reused - fluentd will open new one
15
+ * so logz.io servers react with TCP resets on a lot of new TCP connection that fluentd will open.
16
+
17
+ ```
18
+ <match your_match>
19
+ type logzio_buffered
20
+ endpoint_url https://listener.logz.io:8071?token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&type=my_type
21
+ output_include_time true
22
+ output_include_tags true
23
+ buffer_type file
24
+ buffer_path /path/to/buffer/file
25
+ flush_interval 2s
26
+ buffer_chunk_limit 1m # Logz.io has bulk limit of 10M. We recommend set this to 1M, to avoid oversized bulks
27
+ </match>
28
+ ```
29
+
30
+ If you absolutly must, use the non-buffered plugin (we really recommend using the buffered)
31
+ ```
32
+ <match your_match>
33
+ type logzio
34
+ endpoint_url http://listener.logz.io:8090?token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
35
+ </match>
36
+ ```
37
+
38
+ ## Parameters
39
+ * **endpoint_url** the url to Logz.io input where `xxx-xxxx...` is your Logz.io access token, and `my_type` is the type of your logs in logz.io
40
+ * **output_include_time** should the appender add a timestamp to your logs on their process time. (recommended)
41
+ * **output_include_tags** should the appender add the fluentd tag to the document, called "fluentd_tag"
42
+ * **http_idle_timeout** timeout in seconds that the http persistent connection will stay open without traffic
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'fluent-plugin-logzio-ng'
7
+ s.version = '0.0.7'
8
+ s.authors = ['Kostiantyn Lysenko', 'Yury Kotov', 'Roi Rav-Hon']
9
+ s.email = ['gshaud@gmail.com', 'bairkan@gmail.com', 'roi@logz.io']
10
+ s.homepage = 'https://github.com/logzio/fluent-plugin-logzio-ng'
11
+ s.summary = %q{Another one Fluentd plugin for output to Logz.io}
12
+ s.description = %q{Another one Fluentd pluging (fluent.org) for output to Logz.io (logz.io)}
13
+ s.license = 'Apache-2.0'
14
+
15
+ s.rubyforge_project = 'fluent-plugin-logzio-ng'
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.require_paths = ['lib']
20
+ s.required_ruby_version = Gem::Requirement.new('>= 2.1.0')
21
+
22
+ s.add_dependency 'net-http-persistent', '~> 2.7'
23
+ s.add_dependency 'fluentd', '~> 0.12'
24
+ s.add_development_dependency 'rake', '~> 10.4'
25
+ s.add_development_dependency 'bundler', '~> 1.10'
26
+ s.add_development_dependency 'rspec', '~> 3.3'
27
+ s.add_development_dependency 'test-unit', '~> 3.1'
28
+ end
@@ -0,0 +1,40 @@
1
+ module Fluent
2
+ class LogzioOutput < Fluent::Output
3
+ Fluent::Plugin.register_output('logzio', self)
4
+ config_param :endpoint_url, :string, default: nil
5
+
6
+ def configure(conf)
7
+ super
8
+ $log.debug "Logzio url #{@endpoint_url}"
9
+ end
10
+
11
+ def start
12
+ super
13
+ require 'net/http/persistent'
14
+ @uri = URI @endpoint_url
15
+ @http = Net::HTTP::Persistent.new 'fluent-plugin-logzio-ng', :ENV
16
+ @http.headers['Content-Type'] = 'application/json'
17
+ end
18
+
19
+ def shutdown
20
+ super
21
+ end
22
+
23
+ def emit(tag, es, chain)
24
+ chain.next
25
+ es.each {|time,record|
26
+ record_json = Yajl.dump(record)
27
+ $log.debug "Record sent #{record_json}"
28
+ post = Net::HTTP::Post.new @uri.request_uri
29
+ post.body = record_json
30
+ begin
31
+ response = @http.request @uri, post
32
+ $log.debug "HTTP Response code #{response.code}"
33
+ $log.error response.body if response.code != '200'
34
+ rescue StandardError
35
+ $log.error "Error connecting to logzio verify the url #{@endpoint_url}"
36
+ end
37
+ }
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,100 @@
1
+ module Fluent
2
+ class LogzioOutputBuffered < Fluent::BufferedOutput
3
+ Fluent::Plugin.register_output('logzio_buffered', self)
4
+ config_param :endpoint_url, :string, default: nil
5
+ config_param :output_include_time, :bool, default: true
6
+ config_param :output_include_tags, :bool, default: true
7
+ config_param :retry_count, :integer, default: 3 # How many times to resend failed bulks. Undocumented because not suppose to be changed
8
+ config_param :http_idle_timeout, :integer, default: 5
9
+
10
+ unless method_defined?(:log)
11
+ define_method('log') { $log }
12
+ end
13
+
14
+ def configure(conf)
15
+ super
16
+ $log.debug "Logzio url #{@endpoint_url}"
17
+ end
18
+
19
+ def start
20
+ super
21
+ require 'net/http/persistent'
22
+ @uri = URI @endpoint_url
23
+ @http = Net::HTTP::Persistent.new 'fluent-plugin-logzio-ng', :ENV
24
+ @http.headers['Content-Type'] = 'text/plain'
25
+ @http.idle_timeout = @http_idle_timeout
26
+ @http.socket_options << [Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, 1]
27
+ $log.debug "Started logzio shipper.."
28
+ end
29
+
30
+ def shutdown
31
+ super
32
+ end
33
+
34
+ def format(tag, time, record)
35
+ [tag, time, record].to_msgpack
36
+ end
37
+
38
+ def write(chunk)
39
+ records = []
40
+
41
+ chunk.msgpack_each {|tag,time,record|
42
+ record['@timestamp'] ||= Time.at(time).iso8601(3) if @output_include_time
43
+ record['fluentd_tags'] ||= tag.to_s if @output_include_tags
44
+ records.push(Yajl.dump(record))
45
+ }
46
+
47
+ $log.debug "Got flush timeout, containing #{records.length} chunks"
48
+
49
+ # Setting our request
50
+ post = Net::HTTP::Post.new @uri.request_uri
51
+
52
+ # Logz.io bulk http endpoint expecting log line with \n delimiter
53
+ post.body = records.join("\n")
54
+
55
+ begin
56
+ response = @http.request @uri, post
57
+ $log.debug "HTTP Response code #{response.code}"
58
+
59
+ if response.code != '200'
60
+
61
+ $log.debug "Got HTTP #{response.code} from logz.io, not giving up just yet"
62
+
63
+ # If any other non-200, we will try to resend it after 2, 4 and 8 seconds. Then we will give up
64
+
65
+ sleep_interval = 2
66
+ @retry_count.times do |counter|
67
+
68
+ $log.debug "Sleeping for #{sleep_interval} seconds, and trying again."
69
+
70
+ sleep(sleep_interval)
71
+
72
+ # Retry
73
+ response = @http.request @uri, post
74
+
75
+ # Sucecss, no further action is needed
76
+ if response.code == 200
77
+
78
+ $log.debug "Successfuly sent the failed bulk."
79
+
80
+ # Breaking out
81
+ break
82
+
83
+ else
84
+
85
+ # Doubling the sleep interval
86
+ sleep_interval *= 2
87
+
88
+ if counter == @retry_count - 1
89
+
90
+ $log.error "Could not send your bulk after 3 tries. Sorry. Got HTTP #{response.code}"
91
+ end
92
+ end
93
+ end
94
+ end
95
+ rescue StandardError => error
96
+ $log.error "Error connecting to logzio. Got exception: #{error}"
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Fluent::LogzioOutputBuffered' do
4
+ let(:driver) { Fluent::Test::BufferedOutputTestDriver.new(Fluent::LogzioOutputBuffered).configure(config) }
5
+ let(:config) do
6
+ %[
7
+ endpoint_url https://logz.io?token=123
8
+ output_include_time false
9
+ ]
10
+ end
11
+
12
+ include_context 'output context'
13
+ include_examples 'output examples'
14
+
15
+ describe 'emit' do
16
+ before(:each) do
17
+ expect(request).to receive(:body=).with(%Q[{"field1":50,"otherfield":99,"fluentd_tags":"test"}\n{"field1":150,"otherfield":199,"fluentd_tags":"test"}])
18
+ expect(Net::HTTP::Post).to receive(:new).with('/?token=123').once.and_return(request)
19
+ expect_any_instance_of(Net::HTTP::Persistent).to receive(:request).once.and_return(response)
20
+ end
21
+
22
+ it 'adds messages to the buffer' do
23
+ driver.emit(record1, time)
24
+ driver.emit(record2, time)
25
+
26
+ driver.expect_format ['test', 0, { 'field1' => 50, 'otherfield' => 99 }].to_msgpack
27
+ driver.expect_format ['test', 0, { 'field1' => 150, 'otherfield' => 199 }].to_msgpack
28
+
29
+ driver.run
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Fluent::LogzioOutput' do
4
+ let(:driver) { Fluent::Test::OutputTestDriver.new(Fluent::LogzioOutput).configure(config) }
5
+ let(:config) { %[endpoint_url https://logz.io?token=123] }
6
+
7
+ include_context 'output context'
8
+ include_examples 'output examples'
9
+
10
+ describe 'emit' do
11
+ before(:each) do
12
+ expect(request).to receive(:body=).with('{"field1":50,"otherfield":99}')
13
+ expect(request).to receive(:body=).with('{"field1":150,"otherfield":199}')
14
+ expect(Net::HTTP::Post).to receive(:new).with('/?token=123').twice.and_return(request)
15
+ expect_any_instance_of(Net::HTTP::Persistent).to receive(:request).twice.and_return(response)
16
+ end
17
+
18
+ it 'sends http requests' do
19
+ driver.run
20
+
21
+ driver.emit(record1, Time.at(time))
22
+ driver.emit(record2, Time.at(time))
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,127 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # The `.rspec` file also contains a few flags that are not defaults but that
16
+ # users commonly want.
17
+ #
18
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
19
+ RSpec.configure do |config|
20
+ # rspec-expectations config goes here. You can use an alternate
21
+ # assertion/expectation library such as wrong or the stdlib/minitest
22
+ # assertions if you prefer.
23
+ config.expect_with :rspec do |expectations|
24
+ # This option will default to `true` in RSpec 4. It makes the `description`
25
+ # and `failure_message` of custom matchers include text for helper methods
26
+ # defined using `chain`, e.g.:
27
+ # be_bigger_than(2).and_smaller_than(4).description
28
+ # # => "be bigger than 2 and smaller than 4"
29
+ # ...rather than:
30
+ # # => "be bigger than 2"
31
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
32
+ end
33
+
34
+ # rspec-mocks config goes here. You can use an alternate test double
35
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
36
+ config.mock_with :rspec do |mocks|
37
+ # Prevents you from mocking or stubbing a method that does not exist on
38
+ # a real object. This is generally recommended, and will default to
39
+ # `true` in RSpec 4.
40
+ mocks.verify_partial_doubles = true
41
+ end
42
+
43
+ # The settings below are suggested to provide a good initial experience
44
+ # with RSpec, but feel free to customize to your heart's content.
45
+ =begin
46
+ # These two settings work together to allow you to limit a spec run
47
+ # to individual examples or groups you care about by tagging them with
48
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
49
+ # get run.
50
+ config.filter_run :focus
51
+ config.run_all_when_everything_filtered = true
52
+
53
+ # Allows RSpec to persist some state between runs in order to support
54
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
55
+ # you configure your source control system to ignore this file.
56
+ config.example_status_persistence_file_path = "spec/examples.txt"
57
+
58
+ # Limits the available syntax to the non-monkey patched syntax that is
59
+ # recommended. For more details, see:
60
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
61
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
62
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
63
+ config.disable_monkey_patching!
64
+
65
+ # This setting enables warnings. It's recommended, but in some cases may
66
+ # be too noisy due to issues in dependencies.
67
+ config.warnings = true
68
+
69
+ # Many RSpec users commonly either run the entire suite or an individual
70
+ # file, and it's useful to allow more verbose output when running an
71
+ # individual spec file.
72
+ if config.files_to_run.one?
73
+ # Use the documentation formatter for detailed output,
74
+ # unless a formatter has already been configured
75
+ # (e.g. via a command-line flag).
76
+ config.default_formatter = 'doc'
77
+ end
78
+
79
+ # Print the 10 slowest examples and example groups at the
80
+ # end of the spec run, to help surface which specs are running
81
+ # particularly slow.
82
+ config.profile_examples = 10
83
+
84
+ # Run specs in random order to surface order dependencies. If you find an
85
+ # order dependency and want to debug it, you can fix the order by providing
86
+ # the seed, which is printed after each run.
87
+ # --seed 1234
88
+ config.order = :random
89
+
90
+ # Seed global randomization in this process using the `--seed` CLI option.
91
+ # Setting this allows you to use `--seed` to deterministically reproduce
92
+ # test failures related to randomization by passing the same `--seed` value
93
+ # as the one that triggered the failure.
94
+ Kernel.srand config.seed
95
+ =end
96
+ require 'net/http/persistent'
97
+ require 'fluent/test'
98
+
99
+ require 'fluent/plugin/out_logzio'
100
+ require 'fluent/plugin/out_logzio_buffered'
101
+ end
102
+
103
+ RSpec.shared_examples 'output examples' do |request_block|
104
+ describe 'endpoint url' do
105
+ subject { instance.endpoint_url }
106
+
107
+ it { should eq 'https://logz.io?token=123' }
108
+ end
109
+ end
110
+
111
+ RSpec.shared_context 'output context' do
112
+ before(:all) { Fluent::Test.setup }
113
+ let(:instance) { driver.instance }
114
+
115
+ let(:time) {0}
116
+ let(:record1) {{ 'field1' => 50, 'otherfield' => 99}}
117
+ let(:record2) {{ 'field1' => 150, 'otherfield' => 199}}
118
+ let(:request) { double }
119
+ let(:response) do
120
+ response = double
121
+
122
+ allow(response).to receive(:code).and_return('200')
123
+
124
+ response
125
+ end
126
+ end
127
+
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-logzio-ng
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.7
5
+ platform: ruby
6
+ authors:
7
+ - Kostiantyn Lysenko
8
+ - Yury Kotov
9
+ - Roi Rav-Hon
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2016-12-23 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: net-http-persistent
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '2.7'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '2.7'
29
+ - !ruby/object:Gem::Dependency
30
+ name: fluentd
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: '0.12'
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '0.12'
43
+ - !ruby/object:Gem::Dependency
44
+ name: rake
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '10.4'
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '10.4'
57
+ - !ruby/object:Gem::Dependency
58
+ name: bundler
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '1.10'
64
+ type: :development
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - "~>"
69
+ - !ruby/object:Gem::Version
70
+ version: '1.10'
71
+ - !ruby/object:Gem::Dependency
72
+ name: rspec
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '3.3'
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - "~>"
83
+ - !ruby/object:Gem::Version
84
+ version: '3.3'
85
+ - !ruby/object:Gem::Dependency
86
+ name: test-unit
87
+ requirement: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: '3.1'
92
+ type: :development
93
+ prerelease: false
94
+ version_requirements: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - "~>"
97
+ - !ruby/object:Gem::Version
98
+ version: '3.1'
99
+ description: Another one Fluentd pluging (fluent.org) for output to Logz.io (logz.io)
100
+ email:
101
+ - gshaud@gmail.com
102
+ - bairkan@gmail.com
103
+ - roi@logz.io
104
+ executables: []
105
+ extensions: []
106
+ extra_rdoc_files: []
107
+ files:
108
+ - ".gitignore"
109
+ - ".rspec"
110
+ - CHANGELOG.md
111
+ - Gemfile
112
+ - LICENSE
113
+ - README.md
114
+ - Rakefile
115
+ - fluent-plugin-logzio-ng.gemspec
116
+ - lib/fluent/plugin/out_logzio.rb
117
+ - lib/fluent/plugin/out_logzio_buffered.rb
118
+ - spec/lib/fluent/plugin/out_logzio_buffered_spec.rb
119
+ - spec/lib/fluent/plugin/out_logzio_spec.rb
120
+ - spec/spec_helper.rb
121
+ homepage: https://github.com/logzio/fluent-plugin-logzio-ng
122
+ licenses:
123
+ - Apache-2.0
124
+ metadata: {}
125
+ post_install_message:
126
+ rdoc_options: []
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: 2.1.0
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ requirements: []
140
+ rubyforge_project: fluent-plugin-logzio-ng
141
+ rubygems_version: 2.5.2
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: Another one Fluentd plugin for output to Logz.io
145
+ test_files:
146
+ - spec/lib/fluent/plugin/out_logzio_buffered_spec.rb
147
+ - spec/lib/fluent/plugin/out_logzio_spec.rb
148
+ - spec/spec_helper.rb