fluent-plugin-logzio 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +64 -0
- data/LICENSE +202 -0
- data/README.md +2 -0
- data/Rakefile +1 -0
- data/fluent-plugin-logzio.gemspec +27 -0
- data/lib/fluent/plugin/out_logzio.rb +40 -0
- data/lib/fluent/plugin/out_logzio_buffered.rb +50 -0
- data/spec/lib/fluent/plugin/out_logzio_buffered_spec.rb +34 -0
- data/spec/lib/fluent/plugin/out_logzio_spec.rb +25 -0
- data/spec/spec_helper.rb +127 -0
- metadata +141 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9d9e0961a29f8c6ca7bae70c7b78db209e54b942
|
4
|
+
data.tar.gz: eae84e948319346fff4f861496e969787e3b34e9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 334047ddd4b9dfae8e62586c8cc81735e3f3a1db1eca1435b9ede750970ff447d376f7d11371ccdc76638b8de3240724d624a42d2e00b43fb405d58a67ca59cb
|
7
|
+
data.tar.gz: bbe2693e8158c6b4d4f774c870d8fc642a8a9a687fa54253fbcfff8a1b15be71a5ad2723dd81b5a4d18c2946c4958ca7a9ff93184d53287767dbf4853b87a325
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
fluent-plugin-logzio (0.0.1)
|
5
|
+
fluentd
|
6
|
+
net-http-persistent (>= 2.7)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
cool.io (1.3.1)
|
12
|
+
diff-lcs (1.2.5)
|
13
|
+
fluentd (0.12.15)
|
14
|
+
cool.io (>= 1.2.2, < 2.0.0)
|
15
|
+
http_parser.rb (>= 0.5.1, < 0.7.0)
|
16
|
+
json (>= 1.4.3)
|
17
|
+
msgpack (>= 0.5.11, < 0.6.0)
|
18
|
+
sigdump (~> 0.2.2)
|
19
|
+
string-scrub (>= 0.0.3)
|
20
|
+
tzinfo (>= 1.0.0)
|
21
|
+
tzinfo-data (>= 1.0.0)
|
22
|
+
yajl-ruby (~> 1.0)
|
23
|
+
http_parser.rb (0.6.0)
|
24
|
+
json (1.8.3)
|
25
|
+
msgpack (0.5.12)
|
26
|
+
net-http-persistent (2.9.4)
|
27
|
+
power_assert (0.2.4)
|
28
|
+
rake (10.4.2)
|
29
|
+
rspec (3.3.0)
|
30
|
+
rspec-core (~> 3.3.0)
|
31
|
+
rspec-expectations (~> 3.3.0)
|
32
|
+
rspec-mocks (~> 3.3.0)
|
33
|
+
rspec-core (3.3.2)
|
34
|
+
rspec-support (~> 3.3.0)
|
35
|
+
rspec-expectations (3.3.1)
|
36
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
+
rspec-support (~> 3.3.0)
|
38
|
+
rspec-mocks (3.3.2)
|
39
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
+
rspec-support (~> 3.3.0)
|
41
|
+
rspec-support (3.3.0)
|
42
|
+
sigdump (0.2.3)
|
43
|
+
string-scrub (0.0.5)
|
44
|
+
test-unit (3.1.3)
|
45
|
+
power_assert
|
46
|
+
thread_safe (0.3.5)
|
47
|
+
tzinfo (1.2.2)
|
48
|
+
thread_safe (~> 0.1)
|
49
|
+
tzinfo-data (1.2015.5)
|
50
|
+
tzinfo (>= 1.0.0)
|
51
|
+
yajl-ruby (1.2.1)
|
52
|
+
|
53
|
+
PLATFORMS
|
54
|
+
ruby
|
55
|
+
|
56
|
+
DEPENDENCIES
|
57
|
+
bundler
|
58
|
+
fluent-plugin-logzio!
|
59
|
+
rake
|
60
|
+
rspec
|
61
|
+
test-unit
|
62
|
+
|
63
|
+
BUNDLED WITH
|
64
|
+
1.10.5
|
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.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,27 @@
|
|
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'
|
7
|
+
s.version = '0.0.1'
|
8
|
+
s.authors = ['Yury Kotov']
|
9
|
+
s.email = ['bairkan@gmail.com']
|
10
|
+
s.homepage = 'https://github.com/logzio/fluent-plugin-logzio'
|
11
|
+
s.summary = %q{Fluentd plugin for output to Logz.io}
|
12
|
+
s.description = %q{Fluentd pluging (fluent.org) for output to Logz.io (logz.io)}
|
13
|
+
|
14
|
+
s.rubyforge_project = 'fluent-plugin-logzio'
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split('\n')
|
18
|
+
s.require_paths = ['lib']
|
19
|
+
s.required_ruby_version = Gem::Requirement.new('>= 1.9.3')
|
20
|
+
|
21
|
+
s.add_dependency 'net-http-persistent', '~> 2.7'
|
22
|
+
s.add_dependency 'fluentd', '~> 0.12'
|
23
|
+
s.add_development_dependency 'rake', '~> 10.4'
|
24
|
+
s.add_development_dependency 'bundler', '~> 0'
|
25
|
+
s.add_development_dependency 'rspec', '~> 3.3'
|
26
|
+
s.add_development_dependency 'test-unit', '~> 3.1'
|
27
|
+
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', :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 = record.to_json
|
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,50 @@
|
|
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 # Recommended
|
6
|
+
|
7
|
+
unless method_defined?(:log)
|
8
|
+
define_method('log') { $log }
|
9
|
+
end
|
10
|
+
|
11
|
+
def configure(conf)
|
12
|
+
super
|
13
|
+
$log.debug "Logzio url #{@endpoint_url}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def start
|
17
|
+
super
|
18
|
+
require 'net/http/persistent'
|
19
|
+
@uri = URI @endpoint_url
|
20
|
+
@http = Net::HTTP::Persistent.new 'fluent-plugin-logzio', :ENV
|
21
|
+
@http.headers['Content-Type'] = 'text'
|
22
|
+
end
|
23
|
+
|
24
|
+
def shutdown
|
25
|
+
super
|
26
|
+
end
|
27
|
+
|
28
|
+
def format(tag, time, record)
|
29
|
+
[tag, time, record].to_msgpack
|
30
|
+
end
|
31
|
+
|
32
|
+
def write(chunk)
|
33
|
+
records = []
|
34
|
+
chunk.msgpack_each {|tag,time,record|
|
35
|
+
record['timestamp'] ||= Time.at(time).iso8601 if @output_include_time
|
36
|
+
records.push(record.to_json)
|
37
|
+
}
|
38
|
+
$log.debug "#{records.length} records sent"
|
39
|
+
post = Net::HTTP::Post.new @uri.request_uri
|
40
|
+
post.body = records.join('\n')
|
41
|
+
begin
|
42
|
+
response = @http.request @uri, post
|
43
|
+
$log.debug "HTTP Response code #{response.code}"
|
44
|
+
$log.error response.body if response.code != '200'
|
45
|
+
rescue StandardError
|
46
|
+
$log.error "Error connecting to logzio verify the url #{@loggly_url}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,34 @@
|
|
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('{"field1":50,"otherfield":99}\n{"field1":150,"otherfield":199}')
|
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
|
+
d = driver
|
24
|
+
|
25
|
+
d.emit(record1, time)
|
26
|
+
d.emit(record2, time)
|
27
|
+
|
28
|
+
d.expect_format ['test', 0, { 'field1' => 50, 'otherfield' => 99 }].to_msgpack
|
29
|
+
d.expect_format ['test', 0, { 'field1' => 150, 'otherfield' => 199 }].to_msgpack
|
30
|
+
|
31
|
+
d.run
|
32
|
+
end
|
33
|
+
end
|
34
|
+
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
|
data/spec/spec_helper.rb
ADDED
@@ -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,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-logzio
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yury Kotov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: net-http-persistent
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: fluentd
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.12'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.4'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.4'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
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: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.3'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: test-unit
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.1'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.1'
|
97
|
+
description: Fluentd pluging (fluent.org) for output to Logz.io (logz.io)
|
98
|
+
email:
|
99
|
+
- bairkan@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rspec"
|
106
|
+
- Gemfile
|
107
|
+
- Gemfile.lock
|
108
|
+
- LICENSE
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- fluent-plugin-logzio.gemspec
|
112
|
+
- lib/fluent/plugin/out_logzio.rb
|
113
|
+
- lib/fluent/plugin/out_logzio_buffered.rb
|
114
|
+
- spec/lib/fluent/plugin/out_logzio_buffered_spec.rb
|
115
|
+
- spec/lib/fluent/plugin/out_logzio_spec.rb
|
116
|
+
- spec/spec_helper.rb
|
117
|
+
homepage: https://github.com/logzio/fluent-plugin-logzio
|
118
|
+
licenses: []
|
119
|
+
metadata: {}
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: 1.9.3
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubyforge_project: fluent-plugin-logzio
|
136
|
+
rubygems_version: 2.4.5
|
137
|
+
signing_key:
|
138
|
+
specification_version: 4
|
139
|
+
summary: Fluentd plugin for output to Logz.io
|
140
|
+
test_files: []
|
141
|
+
has_rdoc:
|