fluent-plugin-http-client 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.rubocop.yml +29 -0
- data/.ruby-version +1 -0
- data/.travis.yml +6 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +202 -0
- data/README.md +69 -0
- data/Rakefile +19 -0
- data/example/fluentd.conf +12 -0
- data/fluent-plugin-http-client.gemspec +52 -0
- data/lib/fluent/plugin/http_client/version.rb +7 -0
- data/lib/fluent/plugin/in_http_client.rb +125 -0
- metadata +291 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6835c3077afc12efd4afd6157bafc3d208cc96798279108d29f4c5772fd0526c
|
4
|
+
data.tar.gz: 45b78f747dddbfc5865f5ee95c9434372be5498f733cbc3bf3549b0a4a090efd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5907e703bf09ac542540773a4e5e9d296156350faf306df6d19ebfcec75a1651c278a59d30aa63d583dc605727d556d0df6f5bab8f473e98f8f16d56a0822894
|
7
|
+
data.tar.gz: 35d19dc658bdab22d22a485be85959ef34f38b0cbe3d95f555f641163c5950bb1ebcc9b2c8f74992c00dabb55ff34a733a14e7b3941d406f7f2047e1524f23e0
|
data/.gitignore
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
/.bundle/
|
2
|
+
/.yardoc
|
3
|
+
/_yardoc/
|
4
|
+
/coverage/
|
5
|
+
/doc/
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/tmp/
|
9
|
+
|
10
|
+
# rspec failure tracking
|
11
|
+
.rspec_status
|
12
|
+
|
13
|
+
# byebug
|
14
|
+
.byebug_history
|
15
|
+
|
16
|
+
# app Gem lock
|
17
|
+
/Gemfile.lock
|
18
|
+
|
19
|
+
# filter example
|
20
|
+
/example/*.rb
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-rake
|
3
|
+
|
4
|
+
AllCops:
|
5
|
+
NewCops: enable
|
6
|
+
TargetRubyVersion: 2.3
|
7
|
+
|
8
|
+
Layout/LineLength:
|
9
|
+
Max: 120
|
10
|
+
|
11
|
+
Metrics/BlockLength:
|
12
|
+
Exclude:
|
13
|
+
- fluent-plugin-http-client.gemspec
|
14
|
+
- 'test/**/*.rb'
|
15
|
+
|
16
|
+
Metrics/ClassLength:
|
17
|
+
Exclude:
|
18
|
+
- 'test/**/*.rb'
|
19
|
+
|
20
|
+
Metrics/MethodLength:
|
21
|
+
Max: 20
|
22
|
+
|
23
|
+
# Style/StringLiterals:
|
24
|
+
# Enabled: true
|
25
|
+
# EnforcedStyle: double_quotes
|
26
|
+
|
27
|
+
Style/StringLiteralsInInterpolation:
|
28
|
+
Enabled: true
|
29
|
+
EnforcedStyle: double_quotes
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.7.6
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
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
@@ -0,0 +1,69 @@
|
|
1
|
+
# fluent-plugin-http-client
|
2
|
+
|
3
|
+
[Fluentd](https://fluentd.org/) plugin that provides http client.
|
4
|
+
|
5
|
+
## Configuration
|
6
|
+
|
7
|
+
You can generate configuration template:
|
8
|
+
|
9
|
+
```
|
10
|
+
$ fluent-plugin-config-format input http-client
|
11
|
+
```
|
12
|
+
|
13
|
+
You can copy and paste generated documents here.
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
### RubyGems
|
18
|
+
|
19
|
+
```
|
20
|
+
$ gem install fluent-plugin-http-client
|
21
|
+
```
|
22
|
+
|
23
|
+
### Bundler
|
24
|
+
|
25
|
+
Add following line to your Gemfile:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
gem "fluent-plugin-http-client"
|
29
|
+
```
|
30
|
+
|
31
|
+
And then execute:
|
32
|
+
|
33
|
+
```
|
34
|
+
$ bundle
|
35
|
+
```
|
36
|
+
|
37
|
+
|
38
|
+
## ToDo
|
39
|
+
|
40
|
+
### add Basic Auth
|
41
|
+
|
42
|
+
### add Token Id auth
|
43
|
+
|
44
|
+
- simple token
|
45
|
+
- token renewal
|
46
|
+
|
47
|
+
### get request time
|
48
|
+
|
49
|
+
example:
|
50
|
+
- http://dpsk.github.io/blog/2013/10/01/track-request-time-with-the-faraday/
|
51
|
+
- https://github.com/lostisland/awesome-faraday
|
52
|
+
|
53
|
+
### allow header injection
|
54
|
+
|
55
|
+
### request header to add in event
|
56
|
+
|
57
|
+
- manage a whitelist ?
|
58
|
+
- manage a blacklist ?
|
59
|
+
|
60
|
+
### response header to add in event
|
61
|
+
|
62
|
+
- manage a whitelist ?
|
63
|
+
- manage a blacklist ?
|
64
|
+
|
65
|
+
## Copyright
|
66
|
+
|
67
|
+
* Copyright(c) 2022- Thomas Tych
|
68
|
+
* License
|
69
|
+
* Apache License, Version 2.0
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rake/testtask'
|
5
|
+
require 'bump/tasks'
|
6
|
+
require 'rubocop/rake_task'
|
7
|
+
|
8
|
+
Rake::TestTask.new(:test) do |t|
|
9
|
+
t.libs.push('lib', 'test')
|
10
|
+
t.test_files = FileList['test/**/test_*.rb']
|
11
|
+
t.verbose = true
|
12
|
+
t.warning = true
|
13
|
+
end
|
14
|
+
|
15
|
+
RuboCop::RakeTask.new do |task|
|
16
|
+
task.requires << 'rubocop-rake'
|
17
|
+
end
|
18
|
+
|
19
|
+
task default: %i[test rubocop]
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/fluent/plugin/http_client/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'fluent-plugin-http-client'
|
7
|
+
spec.version = Fluent::Plugin::HttpClient::VERSION
|
8
|
+
spec.authors = ['Thomas Tych']
|
9
|
+
spec.email = ['thomas.tych@gmail.com']
|
10
|
+
|
11
|
+
spec.summary = 'http client for fluentd'
|
12
|
+
spec.description = 'http client for fluentd, based on faraday 2'
|
13
|
+
spec.homepage = 'https://gitlab.com/ttych/fluent-plugin-http-client'
|
14
|
+
spec.license = 'Apache-2.0'
|
15
|
+
|
16
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
17
|
+
|
18
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
19
|
+
|
20
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
21
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
22
|
+
spec.metadata['changelog_uri'] = "#{spec.homepage}/CHANGELOG.md"
|
23
|
+
|
24
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
25
|
+
|
26
|
+
# Specify which files should be added to the gem when it is released.
|
27
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
28
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
29
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
30
|
+
f.match(%r{\A(?:test|spec|features)/})
|
31
|
+
end
|
32
|
+
end
|
33
|
+
spec.bindir = 'exe'
|
34
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
35
|
+
spec.require_paths = ['lib']
|
36
|
+
|
37
|
+
spec.add_development_dependency 'bump', '~> 0.10.0'
|
38
|
+
spec.add_development_dependency 'bundler', '~> 2.1.4'
|
39
|
+
spec.add_development_dependency 'byebug', '~> 11.1', '>= 11.1.1'
|
40
|
+
spec.add_development_dependency 'flay', '~> 2.13'
|
41
|
+
spec.add_development_dependency 'flog', '~> 4.6', '>= 4.6.6'
|
42
|
+
spec.add_development_dependency 'rake', '~> 13.0.1'
|
43
|
+
spec.add_development_dependency 'reek', '~> 6.1', '>= 6.1.0'
|
44
|
+
spec.add_development_dependency 'rubocop', '~> 1.33', '>= 1.33.0'
|
45
|
+
spec.add_development_dependency 'rubocop-rake', '~> 0.6.0'
|
46
|
+
spec.add_development_dependency 'simplecov', '~> 0.21.2'
|
47
|
+
spec.add_development_dependency 'test-unit', '~> 3.3.4'
|
48
|
+
|
49
|
+
spec.add_runtime_dependency 'faraday', '~> 2.5', '>= 2.0.1'
|
50
|
+
spec.add_runtime_dependency 'faraday-retry', '~> 2.0'
|
51
|
+
spec.add_runtime_dependency 'fluentd', ['>= 0.14.10', '< 2']
|
52
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Copyright 2022- Thomas Tych
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
|
18
|
+
require 'fluent/plugin/input'
|
19
|
+
|
20
|
+
require 'faraday'
|
21
|
+
require 'faraday/net_http'
|
22
|
+
require 'faraday/retry'
|
23
|
+
|
24
|
+
module Fluent
|
25
|
+
module Plugin
|
26
|
+
# HttpClientInput: a plugin to pull http server
|
27
|
+
class HttpClientInput < Fluent::Plugin::Input
|
28
|
+
Fluent::Plugin.register_input('http_client', self)
|
29
|
+
|
30
|
+
DEFAULT_USER_AGENT = 'fluent-plugin-http-client'
|
31
|
+
|
32
|
+
helpers :timer, :compat_parameters
|
33
|
+
|
34
|
+
# behavior
|
35
|
+
desc 'The interval time between request execution'
|
36
|
+
config_param :interval, :time, default: 30
|
37
|
+
desc 'The tag of the event is emitted on'
|
38
|
+
config_param :tag, :string
|
39
|
+
# http
|
40
|
+
desc 'The url to request'
|
41
|
+
config_param :url, :string
|
42
|
+
desc 'The http method for each request'
|
43
|
+
config_param :http_method, :enum, list: %i[get post delete], default: :get
|
44
|
+
desc 'The timeout in second for each request'
|
45
|
+
config_param :timeout, :integer, default: 5
|
46
|
+
desc 'verify_ssl'
|
47
|
+
config_param :verify_ssl, :bool, default: true
|
48
|
+
desc 'The absolute path of directory where ca_file stored'
|
49
|
+
config_param :ca_path, :string, default: nil
|
50
|
+
desc 'The absolute path of ca_file'
|
51
|
+
config_param :ca_file, :string, default: nil
|
52
|
+
|
53
|
+
def configure(conf)
|
54
|
+
compat_parameters_convert(conf, :parser)
|
55
|
+
|
56
|
+
super
|
57
|
+
|
58
|
+
configure_client
|
59
|
+
end
|
60
|
+
|
61
|
+
def start
|
62
|
+
super
|
63
|
+
|
64
|
+
timer_execute(:in_http_client_timer, @interval, &method(:on_timer_request))
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def configure_client
|
70
|
+
@client = Faraday.new(client_options) do |f|
|
71
|
+
f.request :retry
|
72
|
+
f.response :json
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def client_options
|
77
|
+
{
|
78
|
+
url: @url,
|
79
|
+
headers: { 'User-Agent' => @user_agent },
|
80
|
+
request: { timeout: @timeout },
|
81
|
+
ssl: { ca_file: @ca_file,
|
82
|
+
ca_path: @ca_path,
|
83
|
+
verify: @verify_ssl }
|
84
|
+
}
|
85
|
+
end
|
86
|
+
|
87
|
+
def headers
|
88
|
+
{ 'User-Agent' => DEFAULT_USER_AGENT }
|
89
|
+
end
|
90
|
+
|
91
|
+
def on_timer_request
|
92
|
+
base_record = {
|
93
|
+
request_url: @url
|
94
|
+
}
|
95
|
+
begin
|
96
|
+
record = do_request
|
97
|
+
rescue StandardError => e
|
98
|
+
record = parse_exception(e)
|
99
|
+
end
|
100
|
+
|
101
|
+
record_time = Engine.now
|
102
|
+
record.update(base_record)
|
103
|
+
router.emit(tag, record_time, record)
|
104
|
+
end
|
105
|
+
|
106
|
+
def do_request
|
107
|
+
response = @client.send(@http_method)
|
108
|
+
|
109
|
+
{
|
110
|
+
status: response.status,
|
111
|
+
success: response.success?,
|
112
|
+
response: response.body
|
113
|
+
}
|
114
|
+
end
|
115
|
+
|
116
|
+
def parse_exception(exception)
|
117
|
+
{
|
118
|
+
status: -1,
|
119
|
+
success: false,
|
120
|
+
error: exception.to_s
|
121
|
+
}
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
metadata
ADDED
@@ -0,0 +1,291 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-http-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Thomas Tych
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-08-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bump
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.10.0
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.10.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.1.4
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.1.4
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: byebug
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '11.1'
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 11.1.1
|
51
|
+
type: :development
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '11.1'
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 11.1.1
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: flay
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '2.13'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '2.13'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: flog
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '4.6'
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: 4.6.6
|
85
|
+
type: :development
|
86
|
+
prerelease: false
|
87
|
+
version_requirements: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - "~>"
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '4.6'
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 4.6.6
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: rake
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 13.0.1
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - "~>"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: 13.0.1
|
109
|
+
- !ruby/object:Gem::Dependency
|
110
|
+
name: reek
|
111
|
+
requirement: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - "~>"
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '6.1'
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: 6.1.0
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '6.1'
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: 6.1.0
|
129
|
+
- !ruby/object:Gem::Dependency
|
130
|
+
name: rubocop
|
131
|
+
requirement: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - "~>"
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '1.33'
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 1.33.0
|
139
|
+
type: :development
|
140
|
+
prerelease: false
|
141
|
+
version_requirements: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '1.33'
|
146
|
+
- - ">="
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: 1.33.0
|
149
|
+
- !ruby/object:Gem::Dependency
|
150
|
+
name: rubocop-rake
|
151
|
+
requirement: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - "~>"
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: 0.6.0
|
156
|
+
type: :development
|
157
|
+
prerelease: false
|
158
|
+
version_requirements: !ruby/object:Gem::Requirement
|
159
|
+
requirements:
|
160
|
+
- - "~>"
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: 0.6.0
|
163
|
+
- !ruby/object:Gem::Dependency
|
164
|
+
name: simplecov
|
165
|
+
requirement: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - "~>"
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: 0.21.2
|
170
|
+
type: :development
|
171
|
+
prerelease: false
|
172
|
+
version_requirements: !ruby/object:Gem::Requirement
|
173
|
+
requirements:
|
174
|
+
- - "~>"
|
175
|
+
- !ruby/object:Gem::Version
|
176
|
+
version: 0.21.2
|
177
|
+
- !ruby/object:Gem::Dependency
|
178
|
+
name: test-unit
|
179
|
+
requirement: !ruby/object:Gem::Requirement
|
180
|
+
requirements:
|
181
|
+
- - "~>"
|
182
|
+
- !ruby/object:Gem::Version
|
183
|
+
version: 3.3.4
|
184
|
+
type: :development
|
185
|
+
prerelease: false
|
186
|
+
version_requirements: !ruby/object:Gem::Requirement
|
187
|
+
requirements:
|
188
|
+
- - "~>"
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
version: 3.3.4
|
191
|
+
- !ruby/object:Gem::Dependency
|
192
|
+
name: faraday
|
193
|
+
requirement: !ruby/object:Gem::Requirement
|
194
|
+
requirements:
|
195
|
+
- - "~>"
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: '2.5'
|
198
|
+
- - ">="
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
version: 2.0.1
|
201
|
+
type: :runtime
|
202
|
+
prerelease: false
|
203
|
+
version_requirements: !ruby/object:Gem::Requirement
|
204
|
+
requirements:
|
205
|
+
- - "~>"
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
version: '2.5'
|
208
|
+
- - ">="
|
209
|
+
- !ruby/object:Gem::Version
|
210
|
+
version: 2.0.1
|
211
|
+
- !ruby/object:Gem::Dependency
|
212
|
+
name: faraday-retry
|
213
|
+
requirement: !ruby/object:Gem::Requirement
|
214
|
+
requirements:
|
215
|
+
- - "~>"
|
216
|
+
- !ruby/object:Gem::Version
|
217
|
+
version: '2.0'
|
218
|
+
type: :runtime
|
219
|
+
prerelease: false
|
220
|
+
version_requirements: !ruby/object:Gem::Requirement
|
221
|
+
requirements:
|
222
|
+
- - "~>"
|
223
|
+
- !ruby/object:Gem::Version
|
224
|
+
version: '2.0'
|
225
|
+
- !ruby/object:Gem::Dependency
|
226
|
+
name: fluentd
|
227
|
+
requirement: !ruby/object:Gem::Requirement
|
228
|
+
requirements:
|
229
|
+
- - ">="
|
230
|
+
- !ruby/object:Gem::Version
|
231
|
+
version: 0.14.10
|
232
|
+
- - "<"
|
233
|
+
- !ruby/object:Gem::Version
|
234
|
+
version: '2'
|
235
|
+
type: :runtime
|
236
|
+
prerelease: false
|
237
|
+
version_requirements: !ruby/object:Gem::Requirement
|
238
|
+
requirements:
|
239
|
+
- - ">="
|
240
|
+
- !ruby/object:Gem::Version
|
241
|
+
version: 0.14.10
|
242
|
+
- - "<"
|
243
|
+
- !ruby/object:Gem::Version
|
244
|
+
version: '2'
|
245
|
+
description: http client for fluentd, based on faraday 2
|
246
|
+
email:
|
247
|
+
- thomas.tych@gmail.com
|
248
|
+
executables: []
|
249
|
+
extensions: []
|
250
|
+
extra_rdoc_files: []
|
251
|
+
files:
|
252
|
+
- ".gitignore"
|
253
|
+
- ".rubocop.yml"
|
254
|
+
- ".ruby-version"
|
255
|
+
- ".travis.yml"
|
256
|
+
- Gemfile
|
257
|
+
- LICENSE.txt
|
258
|
+
- README.md
|
259
|
+
- Rakefile
|
260
|
+
- example/fluentd.conf
|
261
|
+
- fluent-plugin-http-client.gemspec
|
262
|
+
- lib/fluent/plugin/http_client/version.rb
|
263
|
+
- lib/fluent/plugin/in_http_client.rb
|
264
|
+
homepage: https://gitlab.com/ttych/fluent-plugin-http-client
|
265
|
+
licenses:
|
266
|
+
- Apache-2.0
|
267
|
+
metadata:
|
268
|
+
homepage_uri: https://gitlab.com/ttych/fluent-plugin-http-client
|
269
|
+
source_code_uri: https://gitlab.com/ttych/fluent-plugin-http-client
|
270
|
+
changelog_uri: https://gitlab.com/ttych/fluent-plugin-http-client/CHANGELOG.md
|
271
|
+
rubygems_mfa_required: 'true'
|
272
|
+
post_install_message:
|
273
|
+
rdoc_options: []
|
274
|
+
require_paths:
|
275
|
+
- lib
|
276
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
277
|
+
requirements:
|
278
|
+
- - ">="
|
279
|
+
- !ruby/object:Gem::Version
|
280
|
+
version: 2.3.0
|
281
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
282
|
+
requirements:
|
283
|
+
- - ">="
|
284
|
+
- !ruby/object:Gem::Version
|
285
|
+
version: '0'
|
286
|
+
requirements: []
|
287
|
+
rubygems_version: 3.1.6
|
288
|
+
signing_key:
|
289
|
+
specification_version: 4
|
290
|
+
summary: http client for fluentd
|
291
|
+
test_files: []
|