fluent-plugin-out-http 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -2
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/fluent-plugin-out-http.gemspec +1 -1
- data/lib/fluent/plugin/out_http.rb +14 -2
- data/test/plugin/script/plugin/formatter_test.rb +21 -0
- data/test/plugin/test_out_http.rb +41 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ec10329a626597058faa33835bcc4b553d28595fc973353e5807f1ffbea4036
|
4
|
+
data.tar.gz: 6ee543bbd1835b69d9bd80cf1b13af9e9f39d3fcd83ee823425408607d8fc240
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9dfb53ea8a4773adf2407646e34cb98c8d789d472220b066a90b51a325fea123a2f9af283c02f2fb304c0e0e3e0df67187d4883c936c8dcb329c90853d533fc6
|
7
|
+
data.tar.gz: 4bb782810c5f9c5bebf2b56c3be308809e6788d35211a814bdfb9b9e15628f866282ee49a9011d64c2682c0eed2bd6c1540d8d2ee63afad0405ef4f67aca86c9
|
data/.travis.yml
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
rvm:
|
2
|
-
- 2.1
|
3
2
|
- 2.2
|
4
3
|
- 2.3
|
5
|
-
- 2.4.
|
4
|
+
- 2.4.5
|
5
|
+
- 2.5.3
|
6
|
+
- 2.6.0
|
6
7
|
- ruby-head
|
7
8
|
|
8
9
|
os:
|
@@ -14,6 +15,9 @@ dist: trusty
|
|
14
15
|
gemfile:
|
15
16
|
- Gemfile
|
16
17
|
|
18
|
+
before_install:
|
19
|
+
- gem update --system=2.7.8
|
20
|
+
|
17
21
|
script: bundle exec rake test
|
18
22
|
|
19
23
|
matrix:
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
4
|
gem.name = "fluent-plugin-out-http"
|
5
|
-
gem.version = "1.1.
|
5
|
+
gem.version = "1.1.4"
|
6
6
|
gem.authors = ["Marica Odagaki"]
|
7
7
|
gem.email = ["ento.entotto@gmail.com"]
|
8
8
|
gem.summary = %q{A generic Fluentd output plugin to send logs to an HTTP endpoint}
|
@@ -6,9 +6,10 @@ require 'fluent/plugin/output'
|
|
6
6
|
class Fluent::Plugin::HTTPOutput < Fluent::Plugin::Output
|
7
7
|
Fluent::Plugin.register_output('http', self)
|
8
8
|
|
9
|
-
helpers :compat_parameters
|
9
|
+
helpers :compat_parameters, :formatter
|
10
10
|
|
11
11
|
DEFAULT_BUFFER_TYPE = "memory"
|
12
|
+
DEFAULT_FORMATTER = "json"
|
12
13
|
|
13
14
|
def initialize
|
14
15
|
super
|
@@ -52,8 +53,12 @@ class Fluent::Plugin::HTTPOutput < Fluent::Plugin::Output
|
|
52
53
|
config_set_default :chunk_keys, ['tag']
|
53
54
|
end
|
54
55
|
|
56
|
+
config_section :format do
|
57
|
+
config_set_default :@type, DEFAULT_FORMATTER
|
58
|
+
end
|
59
|
+
|
55
60
|
def configure(conf)
|
56
|
-
compat_parameters_convert(conf, :buffer)
|
61
|
+
compat_parameters_convert(conf, :buffer, :formatter)
|
57
62
|
super
|
58
63
|
|
59
64
|
@ssl_verify_mode = if @ssl_no_verify
|
@@ -65,6 +70,10 @@ class Fluent::Plugin::HTTPOutput < Fluent::Plugin::Output
|
|
65
70
|
@ca_file = @cacert_file
|
66
71
|
@last_request_time = nil
|
67
72
|
raise Fluent::ConfigError, "'tag' in chunk_keys is required." if !@chunk_key_tag && @buffered
|
73
|
+
|
74
|
+
if @formatter_config = conf.elements('format').first
|
75
|
+
@formatter = formatter_create
|
76
|
+
end
|
68
77
|
end
|
69
78
|
|
70
79
|
def start
|
@@ -179,6 +188,9 @@ class Fluent::Plugin::HTTPOutput < Fluent::Plugin::Output
|
|
179
188
|
end # end send_request
|
180
189
|
|
181
190
|
def handle_record(tag, time, record)
|
191
|
+
if @formatter_config
|
192
|
+
record = @formatter.format(tag, time, record)
|
193
|
+
end
|
182
194
|
req, uri = create_request(tag, time, record)
|
183
195
|
send_request(req, uri)
|
184
196
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'fluent/plugin/formatter'
|
2
|
+
|
3
|
+
module Fluent
|
4
|
+
module Plugin
|
5
|
+
class TestFormatter < Formatter
|
6
|
+
Fluent::Plugin.register_formatter('test', self)
|
7
|
+
|
8
|
+
def configure(conf)
|
9
|
+
super
|
10
|
+
end
|
11
|
+
|
12
|
+
def format(tag, time, record)
|
13
|
+
output = {
|
14
|
+
"wrapped" => true,
|
15
|
+
"record" => record
|
16
|
+
}
|
17
|
+
output
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -6,6 +6,7 @@ require 'fluent/test/http_output_test'
|
|
6
6
|
require 'fluent/plugin/out_http'
|
7
7
|
require 'fluent/test/driver/output'
|
8
8
|
require 'fluent/test/helpers'
|
9
|
+
require_relative "./script/plugin/formatter_test"
|
9
10
|
|
10
11
|
module OS
|
11
12
|
# ref. http://stackoverflow.com/questions/170956/how-can-i-find-which-operating-system-my-ruby-program-is-running-on
|
@@ -579,6 +580,46 @@ class HTTPOutputTest < HTTPOutputTestBase
|
|
579
580
|
assert_equal 2, @prohibited
|
580
581
|
end
|
581
582
|
|
583
|
+
class CustomFormatterTest < self
|
584
|
+
def test_new_config
|
585
|
+
config = Fluent::Config::Element.new(
|
586
|
+
'ROOT', '',
|
587
|
+
{"@type" => "http",
|
588
|
+
"endpoint_url" => "http://127.0.0.1:#{self.class.port}/api/",
|
589
|
+
"serializer" => "json"}, [
|
590
|
+
Fluent::Config::Element.new('format', '', {
|
591
|
+
"@type" => "test"
|
592
|
+
}, [])
|
593
|
+
])
|
594
|
+
d = create_driver config
|
595
|
+
payload = {"field" => 1}
|
596
|
+
d.run(default_tag: 'test.metrics') do
|
597
|
+
d.feed(payload)
|
598
|
+
end
|
599
|
+
|
600
|
+
record = @posts[0]
|
601
|
+
expected = {"wrapped" => true, "record" => payload}
|
602
|
+
assert_equal expected, record[:json]
|
603
|
+
end
|
604
|
+
|
605
|
+
def test_legacy_config
|
606
|
+
config = %[
|
607
|
+
endpoint_url http://127.0.0.1:#{self.class.port}/api/
|
608
|
+
serializer json
|
609
|
+
format test
|
610
|
+
]
|
611
|
+
|
612
|
+
d = create_driver config
|
613
|
+
payload = {"field" => 1}
|
614
|
+
d.run(default_tag: 'test.metrics') do
|
615
|
+
d.feed(payload)
|
616
|
+
end
|
617
|
+
|
618
|
+
record = @posts[0]
|
619
|
+
expected = {"wrapped" => true, "record" => payload}
|
620
|
+
assert_equal expected, record[:json]
|
621
|
+
end
|
622
|
+
end
|
582
623
|
end
|
583
624
|
|
584
625
|
class HTTPSOutputTest < HTTPOutputTestBase
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-out-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marica Odagaki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yajl-ruby
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- fluent-plugin-out-http.gemspec
|
105
105
|
- lib/fluent/plugin/out_http.rb
|
106
106
|
- lib/fluent/test/http_output_test.rb
|
107
|
+
- test/plugin/script/plugin/formatter_test.rb
|
107
108
|
- test/plugin/test_out_http.rb
|
108
109
|
homepage: https://github.com/fluent-plugins-nursery/fluent-plugin-out-http
|
109
110
|
licenses:
|
@@ -124,10 +125,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
125
|
- !ruby/object:Gem::Version
|
125
126
|
version: '0'
|
126
127
|
requirements: []
|
127
|
-
|
128
|
-
rubygems_version: 2.7.6
|
128
|
+
rubygems_version: 3.0.1
|
129
129
|
signing_key:
|
130
130
|
specification_version: 4
|
131
131
|
summary: A generic Fluentd output plugin to send logs to an HTTP endpoint
|
132
132
|
test_files:
|
133
|
+
- test/plugin/script/plugin/formatter_test.rb
|
133
134
|
- test/plugin/test_out_http.rb
|