fluent-plugin-out-http 1.3.3 → 1.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/test.yml +43 -0
- data/CHANGELOG.md +8 -0
- data/README.md +38 -0
- data/fluent-plugin-out-http.gemspec +3 -1
- data/lib/fluent/plugin/out_http.rb +17 -4
- data/run_test.rb +4 -0
- data/test/plugin/test_out_http.rb +60 -3
- metadata +34 -7
- data/.travis.yml +0 -24
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d3d0fe7b452afa815821161d819bdf70c394e10068d43ad9d7962f9e59506585
|
|
4
|
+
data.tar.gz: e6e6b6b72bda444045c274cdf1b4edc5d61da372f330b2697b09d16134072a92
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7e3e2600427b82ec559a99411423cd161e7fd99146cb2beffb1467fc0f997297f59d3cb352b29cae717b5fc012b1122edc80f9a29087d26e0c9400a56ce9a37e
|
|
7
|
+
data.tar.gz: 2dd79aa067059bcd8626bc0d65230283f850996ea861fd792c53e8ea92c47cdf12a11c4823bc81309fecf28241390354a7dff8ce46d348c1fcfbb48a43c5b8da
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
name: Test
|
|
2
|
+
on:
|
|
3
|
+
- push
|
|
4
|
+
- pull_request
|
|
5
|
+
jobs:
|
|
6
|
+
build:
|
|
7
|
+
runs-on: ${{ matrix.os }}
|
|
8
|
+
strategy:
|
|
9
|
+
fail-fast: false
|
|
10
|
+
matrix:
|
|
11
|
+
ruby: [ '2.7', '3.0', '3.1', '3.2', '3.3', '3.4', '4.0' ]
|
|
12
|
+
os:
|
|
13
|
+
- ubuntu-latest
|
|
14
|
+
- macOS-latest
|
|
15
|
+
name: Ruby ${{ matrix.ruby }} unit testing on ${{ matrix.os }}
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
18
|
+
- uses: ruby/setup-ruby@6ca151fd1bfcfd6fe0c4eb6837eb0584d0134a0c # v1.290.0
|
|
19
|
+
with:
|
|
20
|
+
ruby-version: ${{ matrix.ruby }}
|
|
21
|
+
bundler-cache: true
|
|
22
|
+
- name: unit testing
|
|
23
|
+
run: |
|
|
24
|
+
bundle exec rake test
|
|
25
|
+
|
|
26
|
+
gem:
|
|
27
|
+
name: Gem test
|
|
28
|
+
runs-on: ubuntu-latest
|
|
29
|
+
steps:
|
|
30
|
+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
31
|
+
- uses: ruby/setup-ruby@6ca151fd1bfcfd6fe0c4eb6837eb0584d0134a0c # v1.290.0
|
|
32
|
+
with:
|
|
33
|
+
ruby-version: 3.1
|
|
34
|
+
- name: Install
|
|
35
|
+
run: |
|
|
36
|
+
rake install
|
|
37
|
+
gem install test-unit test-unit-rr webrick
|
|
38
|
+
- name: Test
|
|
39
|
+
run: |
|
|
40
|
+
mkdir -p tmp
|
|
41
|
+
cd tmp
|
|
42
|
+
cp -a ../test/ ./
|
|
43
|
+
../run_test.rb
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -2,8 +2,38 @@
|
|
|
2
2
|
|
|
3
3
|
A generic [fluentd][1] output plugin for sending logs to an HTTP endpoint.
|
|
4
4
|
|
|
5
|
+
**NOTE:** This plugin name is overlapped from Fluentd core plugin which name is `out_http`. But core plugin does not provide buffered/non-buffered switch and batch/non-batch request switch. If you want to use these switch features. Please consider to use this plugin.
|
|
6
|
+
|
|
5
7
|
[](https://travis-ci.org/fluent-plugins-nursery/fluent-plugin-out-http)
|
|
6
8
|
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
### For bundler
|
|
12
|
+
|
|
13
|
+
Write the following line in Gemfile:
|
|
14
|
+
|
|
15
|
+
```gemfile
|
|
16
|
+
gem "fluent-plugin-out-http"
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
and then,
|
|
20
|
+
|
|
21
|
+
```console
|
|
22
|
+
$ bundle install
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### for fluentd
|
|
26
|
+
|
|
27
|
+
```console
|
|
28
|
+
$ fluent-gem install fluent-plugin-out-http
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### For td-agent
|
|
32
|
+
|
|
33
|
+
```console
|
|
34
|
+
$ td-agent-gem install fluent-plugin-out-http
|
|
35
|
+
```
|
|
36
|
+
|
|
7
37
|
## Configuration options
|
|
8
38
|
|
|
9
39
|
<match *>
|
|
@@ -45,3 +75,11 @@ Heavily based on [fluent-plugin-growthforecast][2]
|
|
|
45
75
|
[1]: http://fluentd.org/
|
|
46
76
|
[2]: https://github.com/tagomoris/fluent-plugin-growthforecast
|
|
47
77
|
[3]: https://github.com/sabottenda/fluent-plugin-bufferize
|
|
78
|
+
|
|
79
|
+
## How to release
|
|
80
|
+
|
|
81
|
+
1. Update `gem.version` of the `gemspec` file.
|
|
82
|
+
1. Update `CHANGELOG.md`.
|
|
83
|
+
1. Commit them.
|
|
84
|
+
1. `$ bundle exec rake release`
|
|
85
|
+
* It will add and push the tag, and publish the gem.
|
|
@@ -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.3.
|
|
5
|
+
gem.version = "1.3.5"
|
|
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}
|
|
@@ -22,4 +22,6 @@ Gem::Specification.new do |gem|
|
|
|
22
22
|
gem.add_development_dependency "bundler"
|
|
23
23
|
gem.add_development_dependency "rake"
|
|
24
24
|
gem.add_development_dependency "test-unit", ">= 3.1.0"
|
|
25
|
+
gem.add_development_dependency "test-unit-rr", "~> 1.0"
|
|
26
|
+
gem.add_development_dependency "webrick"
|
|
25
27
|
end
|
|
@@ -61,7 +61,7 @@ class Fluent::Plugin::HTTPOutput < Fluent::Plugin::Output
|
|
|
61
61
|
config_param :authentication, :enum, list: [:none, :basic, :jwt, :bearer], :default => :none
|
|
62
62
|
config_param :username, :string, :default => ''
|
|
63
63
|
config_param :password, :string, :default => '', :secret => true
|
|
64
|
-
config_param :token, :string, :default => ''
|
|
64
|
+
config_param :token, :string, :default => '', :secret => true
|
|
65
65
|
# Switch non-buffered/buffered plugin
|
|
66
66
|
config_param :buffered, :bool, :default => false
|
|
67
67
|
config_param :bulk_request, :bool, :default => false
|
|
@@ -146,12 +146,21 @@ class Fluent::Plugin::HTTPOutput < Fluent::Plugin::Output
|
|
|
146
146
|
end
|
|
147
147
|
end
|
|
148
148
|
|
|
149
|
+
def buffer_compressed?
|
|
150
|
+
@buffered && @buffer.compress == :gzip
|
|
151
|
+
end
|
|
152
|
+
|
|
149
153
|
def compress_body(req, data)
|
|
150
154
|
return unless @compress_request
|
|
151
|
-
gz = Zlib::GzipWriter.new(StringIO.new)
|
|
152
|
-
gz << data
|
|
153
155
|
|
|
154
156
|
req['Content-Encoding'] = "gzip"
|
|
157
|
+
if buffer_compressed?
|
|
158
|
+
req.body = data
|
|
159
|
+
return
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
gz = Zlib::GzipWriter.new(StringIO.new)
|
|
163
|
+
gz << data
|
|
155
164
|
req.body = gz.close.string
|
|
156
165
|
end
|
|
157
166
|
|
|
@@ -261,7 +270,8 @@ class Fluent::Plugin::HTTPOutput < Fluent::Plugin::Output
|
|
|
261
270
|
end
|
|
262
271
|
|
|
263
272
|
def handle_records(tag, time, chunk)
|
|
264
|
-
|
|
273
|
+
record = buffer_compressed? ? chunk.read(compressed: @buffer.compress) : chunk.read
|
|
274
|
+
req, uri = create_request(tag, time, record)
|
|
265
275
|
send_request(req, uri)
|
|
266
276
|
end
|
|
267
277
|
|
|
@@ -302,6 +312,9 @@ class Fluent::Plugin::HTTPOutput < Fluent::Plugin::Output
|
|
|
302
312
|
def write(chunk)
|
|
303
313
|
tag = chunk.metadata.tag
|
|
304
314
|
@endpoint_url = extract_placeholders(@endpoint_url, chunk)
|
|
315
|
+
|
|
316
|
+
log.debug { "#{@http_method.capitalize} data to #{@endpoint_url} with chunk(#{dump_unique_id_hex(chunk.unique_id)})" }
|
|
317
|
+
|
|
305
318
|
if @bulk_request
|
|
306
319
|
time = Fluent::Engine.now
|
|
307
320
|
handle_records(tag, time, chunk)
|
data/run_test.rb
ADDED
|
@@ -8,6 +8,8 @@ require 'fluent/test/driver/output'
|
|
|
8
8
|
require 'fluent/test/helpers'
|
|
9
9
|
require_relative "./script/plugin/formatter_test"
|
|
10
10
|
|
|
11
|
+
require 'test/unit/rr'
|
|
12
|
+
|
|
11
13
|
module OS
|
|
12
14
|
# ref. http://stackoverflow.com/questions/170956/how-can-i-find-which-operating-system-my-ruby-program-is-running-on
|
|
13
15
|
def OS.windows?
|
|
@@ -100,9 +102,18 @@ class HTTPOutputTestBase < Test::Unit::TestCase
|
|
|
100
102
|
|
|
101
103
|
expander = -> (req) {
|
|
102
104
|
if req["Content-Encoding"] == "gzip"
|
|
103
|
-
StringIO.
|
|
104
|
-
|
|
105
|
-
|
|
105
|
+
sio = StringIO.new(req.body)
|
|
106
|
+
output = ""
|
|
107
|
+
|
|
108
|
+
until sio.eof?
|
|
109
|
+
gz = Zlib::GzipReader.new(sio)
|
|
110
|
+
output << gz.read
|
|
111
|
+
unused = gz.unused
|
|
112
|
+
if unused
|
|
113
|
+
sio.pos -= unused.length
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
output
|
|
106
117
|
else
|
|
107
118
|
req.body
|
|
108
119
|
end
|
|
@@ -523,6 +534,50 @@ class HTTPOutputTest < HTTPOutputTestBase
|
|
|
523
534
|
assert_equal expected, record[:x_ndjson]
|
|
524
535
|
assert_nil record[:auth]
|
|
525
536
|
end
|
|
537
|
+
|
|
538
|
+
def test_emit_x_ndjson_with_compression_with_compressed_buffer
|
|
539
|
+
binary_string = "\xe3\x81\x82"
|
|
540
|
+
d = create_driver CONFIG_JSON + %[
|
|
541
|
+
buffered true
|
|
542
|
+
bulk_request true
|
|
543
|
+
compress_request true
|
|
544
|
+
<buffer>
|
|
545
|
+
@type memory
|
|
546
|
+
compress gzip
|
|
547
|
+
</buffer>
|
|
548
|
+
]
|
|
549
|
+
|
|
550
|
+
# Should not recompress
|
|
551
|
+
dont_allow(Zlib::GzipWriter).new
|
|
552
|
+
|
|
553
|
+
d.run(default_tag: 'test.metrics') do
|
|
554
|
+
d.feed({ 'field1' => 50, 'field2' => 20, 'field3' => 10, 'otherfield' => 1, 'binary' => binary_string })
|
|
555
|
+
d.feed({ 'field1' => 70, 'field2' => 30, 'field3' => 20, 'otherfield' => 2, 'binary' => binary_string })
|
|
556
|
+
end
|
|
557
|
+
|
|
558
|
+
assert_equal 1, @posts.size
|
|
559
|
+
record = @posts[0]
|
|
560
|
+
|
|
561
|
+
expected =[
|
|
562
|
+
{
|
|
563
|
+
"binary" => "\u3042",
|
|
564
|
+
"field1" => 50,
|
|
565
|
+
"field2" => 20,
|
|
566
|
+
"field3" => 10,
|
|
567
|
+
"otherfield" => 1
|
|
568
|
+
},
|
|
569
|
+
{
|
|
570
|
+
"binary" => "\u3042",
|
|
571
|
+
"field1" => 70,
|
|
572
|
+
"field2" => 30,
|
|
573
|
+
"field3" => 20,
|
|
574
|
+
"otherfield" => 2
|
|
575
|
+
}
|
|
576
|
+
]
|
|
577
|
+
|
|
578
|
+
assert_equal expected, record[:x_ndjson]
|
|
579
|
+
assert_nil record[:auth]
|
|
580
|
+
end
|
|
526
581
|
end
|
|
527
582
|
|
|
528
583
|
def test_emit_form_put
|
|
@@ -859,6 +914,8 @@ class HTTPSOutputTest < HTTPOutputTestBase
|
|
|
859
914
|
ssl_no_verify true
|
|
860
915
|
cacert_file /tmp/ssl.cert
|
|
861
916
|
]
|
|
917
|
+
cert, _ = WEBrick::Utils.create_self_signed_cert(2048, [["CN", "localhost"]], "Generated Test Cert")
|
|
918
|
+
File.write('/tmp/ssl.cert', cert.to_pem)
|
|
862
919
|
d = create_driver config
|
|
863
920
|
d.run(default_tag: 'test.metrics') do
|
|
864
921
|
d.feed({ 'field1' => 50 })
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fluent-plugin-out-http
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.
|
|
4
|
+
version: 1.3.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Marica Odagaki
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: yajl-ruby
|
|
@@ -86,6 +85,34 @@ dependencies:
|
|
|
86
85
|
- - ">="
|
|
87
86
|
- !ruby/object:Gem::Version
|
|
88
87
|
version: 3.1.0
|
|
88
|
+
- !ruby/object:Gem::Dependency
|
|
89
|
+
name: test-unit-rr
|
|
90
|
+
requirement: !ruby/object:Gem::Requirement
|
|
91
|
+
requirements:
|
|
92
|
+
- - "~>"
|
|
93
|
+
- !ruby/object:Gem::Version
|
|
94
|
+
version: '1.0'
|
|
95
|
+
type: :development
|
|
96
|
+
prerelease: false
|
|
97
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
98
|
+
requirements:
|
|
99
|
+
- - "~>"
|
|
100
|
+
- !ruby/object:Gem::Version
|
|
101
|
+
version: '1.0'
|
|
102
|
+
- !ruby/object:Gem::Dependency
|
|
103
|
+
name: webrick
|
|
104
|
+
requirement: !ruby/object:Gem::Requirement
|
|
105
|
+
requirements:
|
|
106
|
+
- - ">="
|
|
107
|
+
- !ruby/object:Gem::Version
|
|
108
|
+
version: '0'
|
|
109
|
+
type: :development
|
|
110
|
+
prerelease: false
|
|
111
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
112
|
+
requirements:
|
|
113
|
+
- - ">="
|
|
114
|
+
- !ruby/object:Gem::Version
|
|
115
|
+
version: '0'
|
|
89
116
|
description: A generic Fluentd output plugin to send logs to an HTTP endpoint
|
|
90
117
|
email:
|
|
91
118
|
- ento.entotto@gmail.com
|
|
@@ -93,8 +120,9 @@ executables: []
|
|
|
93
120
|
extensions: []
|
|
94
121
|
extra_rdoc_files: []
|
|
95
122
|
files:
|
|
123
|
+
- ".github/dependabot.yml"
|
|
124
|
+
- ".github/workflows/test.yml"
|
|
96
125
|
- ".gitignore"
|
|
97
|
-
- ".travis.yml"
|
|
98
126
|
- CHANGELOG.md
|
|
99
127
|
- Gemfile
|
|
100
128
|
- ISSUE_TEMPLATE.md
|
|
@@ -104,13 +132,13 @@ files:
|
|
|
104
132
|
- fluent-plugin-out-http.gemspec
|
|
105
133
|
- lib/fluent/plugin/out_http.rb
|
|
106
134
|
- lib/fluent/test/http_output_test.rb
|
|
135
|
+
- run_test.rb
|
|
107
136
|
- test/plugin/script/plugin/formatter_test.rb
|
|
108
137
|
- test/plugin/test_out_http.rb
|
|
109
138
|
homepage: https://github.com/fluent-plugins-nursery/fluent-plugin-out-http
|
|
110
139
|
licenses:
|
|
111
140
|
- Apache-2.0
|
|
112
141
|
metadata: {}
|
|
113
|
-
post_install_message:
|
|
114
142
|
rdoc_options: []
|
|
115
143
|
require_paths:
|
|
116
144
|
- lib
|
|
@@ -125,8 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
125
153
|
- !ruby/object:Gem::Version
|
|
126
154
|
version: '0'
|
|
127
155
|
requirements: []
|
|
128
|
-
rubygems_version:
|
|
129
|
-
signing_key:
|
|
156
|
+
rubygems_version: 4.0.6
|
|
130
157
|
specification_version: 4
|
|
131
158
|
summary: A generic Fluentd output plugin to send logs to an HTTP endpoint
|
|
132
159
|
test_files:
|
data/.travis.yml
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
rvm:
|
|
2
|
-
- 2.4.6
|
|
3
|
-
- 2.5.6
|
|
4
|
-
- 2.6.4
|
|
5
|
-
- ruby-head
|
|
6
|
-
|
|
7
|
-
os:
|
|
8
|
-
- linux
|
|
9
|
-
- osx
|
|
10
|
-
osx_image: xcode11.2
|
|
11
|
-
|
|
12
|
-
dist: trusty
|
|
13
|
-
|
|
14
|
-
gemfile:
|
|
15
|
-
- Gemfile
|
|
16
|
-
|
|
17
|
-
before_install:
|
|
18
|
-
- gem update --system=2.7.8
|
|
19
|
-
|
|
20
|
-
script: bundle exec rake test
|
|
21
|
-
|
|
22
|
-
matrix:
|
|
23
|
-
allow_failures:
|
|
24
|
-
- rvm: ruby-head
|