fluent-plugin-out-kivera 1.0.2 → 1.0.4
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/workflows/test.yml +43 -0
- data/CHANGELOG.md +4 -0
- data/Makefile +12 -0
- data/README.md +35 -23
- data/fluent-plugin-out-kivera.gemspec +2 -2
- data/lib/fluent/plugin/out_kivera.rb +16 -11
- data/run_test.rb +4 -0
- metadata +7 -9
- data/.github/workflows/linux.yml +0 -26
- data/.github/workflows/macos.yml +0 -26
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 721bfd6a1f2d3a7fd4c1b0f32f4c0b9c719f893efceb5e4efc85d120a584cfd0
|
|
4
|
+
data.tar.gz: 4e5570fb109cc3a10611943feb6d5a969e1bb622e465f265fb64a7f690446199
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c12450c146eac19c5a4ad93c981d65b7a37380079a0be5b76f8e26ee80536efaf423d7ac25d79c77cce10151a6da38e7b3595e7ff7801b0fe4bc8e5e66e2129a
|
|
7
|
+
data.tar.gz: 1b739bbcc134e71c865c0c431b169717e8a287d43f93ef4434e17f9eeb2495e120a9490e0c3d609542ed1beb797ba92816bf7bd8d4224ec698ca4ce0cb457a01
|
|
@@ -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' ]
|
|
12
|
+
# os:
|
|
13
|
+
# - ubuntu-latest
|
|
14
|
+
# - macOS-latest
|
|
15
|
+
# name: Ruby ${{ matrix.ruby }} unit testing on ${{ matrix.os }}
|
|
16
|
+
# steps:
|
|
17
|
+
# - uses: actions/checkout@v3
|
|
18
|
+
# - uses: ruby/setup-ruby@v1
|
|
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@v3
|
|
31
|
+
# - uses: ruby/setup-ruby@v1
|
|
32
|
+
# with:
|
|
33
|
+
# ruby-version: 3.1
|
|
34
|
+
# - name: Install
|
|
35
|
+
# run: |
|
|
36
|
+
# rake install
|
|
37
|
+
# gem install test-unit 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/Makefile
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
SHELL=/bin/bash
|
|
2
|
+
.ONESHELL:
|
|
3
|
+
.EXPORT_ALL_VARIABLES:
|
|
4
|
+
|
|
5
|
+
build:
|
|
6
|
+
@if [ "${VER}" = "" ]; then echo "VER not set"; exit 1; else echo "VER=${VER}"; fi
|
|
7
|
+
sed -i '' 's/ gem.version.*/ gem.version = "${VER}"/g' fluent-plugin-out-kivera.gemspec
|
|
8
|
+
gem build fluent-plugin-out-kivera
|
|
9
|
+
|
|
10
|
+
push:
|
|
11
|
+
@if [ "${VER}" = "" ]; then echo "VER not set"; exit 1; else echo "VER=${VER}"; fi
|
|
12
|
+
gem push fluent-plugin-out-kivera-${VER}.gem
|
data/README.md
CHANGED
|
@@ -6,39 +6,43 @@ A generic [fluentd][1] output plugin for sending Kivera proxy logs to the Kivera
|
|
|
6
6
|
|
|
7
7
|
You can specify the path to a config.json file which can contain the following parameters:
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
*config.json*
|
|
10
|
+
```
|
|
11
|
+
{
|
|
11
12
|
"client_id": "",
|
|
12
13
|
"client_secret": "",
|
|
13
14
|
"audience": "",
|
|
14
15
|
"auth0_domain": "",
|
|
15
16
|
"auth0_cert": "",
|
|
16
17
|
"auth0_cert_file": ""
|
|
17
|
-
|
|
18
|
+
}
|
|
19
|
+
```
|
|
18
20
|
|
|
19
21
|
Note that parameter specified within the config_file will take precendence over parameters specified in your fluent.conf.
|
|
20
22
|
Also note that the auth0_cert parameter will take precedence over the auth0_cert_file parameter.
|
|
21
23
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
24
|
+
*fluent.conf*
|
|
25
|
+
```
|
|
26
|
+
<match *>
|
|
27
|
+
@type kivera
|
|
28
|
+
endpoint_url http://localhost.local/api/
|
|
29
|
+
config_file /path/to/config_file.json
|
|
30
|
+
client_id abc123
|
|
31
|
+
client_secret def456
|
|
32
|
+
audience http://api.kivera.io
|
|
33
|
+
auth0_domain auth.nonp.kivera.io
|
|
34
|
+
auth0_cert -----BEGIN CERTIFICATE-----...
|
|
35
|
+
auth0_cert_file /path/to/auth0_cert_file
|
|
36
|
+
ssl_no_verify false # default: false
|
|
37
|
+
rate_limit_msec 100 # default: 0 = no rate limiting
|
|
38
|
+
raise_on_error false # default: true
|
|
39
|
+
recoverable_status_codes 503, 400 # default: 503
|
|
40
|
+
custom_headers {"token":"arbitrary"} # default: nil
|
|
41
|
+
buffered true # default: false. Switch non-buffered/buffered mode
|
|
42
|
+
bulk_request true # default: true. Send events as application/x-ndjson
|
|
43
|
+
compress_request true # default: false. Send compressed events
|
|
44
|
+
</match>
|
|
45
|
+
```
|
|
42
46
|
|
|
43
47
|
## Usage notes
|
|
44
48
|
|
|
@@ -56,3 +60,11 @@ Heavily based on [fluent-plugin-out-http][2]
|
|
|
56
60
|
[1]: http://fluentd.org/
|
|
57
61
|
[2]: https://github.com/fluent-plugins-nursery/fluent-plugin-out-http
|
|
58
62
|
[3]: https://github.com/sabottenda/fluent-plugin-bufferize
|
|
63
|
+
|
|
64
|
+
## How to release
|
|
65
|
+
|
|
66
|
+
1. Update `gem.version` of the `gemspec` file.
|
|
67
|
+
1. Update `CHANGELOG.md`.
|
|
68
|
+
1. Commit them.
|
|
69
|
+
1. `$ bundle exec rake release`
|
|
70
|
+
* It will add and push the tag, and publish the gem.
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |gem|
|
|
4
4
|
gem.name = "fluent-plugin-out-kivera"
|
|
5
|
-
gem.version = "1.0.
|
|
5
|
+
gem.version = "1.0.4"
|
|
6
6
|
gem.authors = ["Tyler Matheson"]
|
|
7
|
-
gem.email = ["
|
|
7
|
+
gem.email = ["tyler@kivera.io"]
|
|
8
8
|
gem.summary = "Fluentd plugin for Kivera"
|
|
9
9
|
gem.description = "A Fluentd output plugin for sending Kivera proxy logs to the Kivera log ingestion service"
|
|
10
10
|
gem.homepage = "https://github.com/kivera-io/fluent-plugin-out-kivera"
|
|
@@ -48,6 +48,9 @@ class Fluent::Plugin::HTTPOutput < Fluent::Plugin::Output
|
|
|
48
48
|
# kivera proxy client secret
|
|
49
49
|
config_param :client_secret, :string, default: ""
|
|
50
50
|
|
|
51
|
+
# Kivera proxy entity secret
|
|
52
|
+
config_param :entity_secret, :string, default: ""
|
|
53
|
+
|
|
51
54
|
# kivera audience api
|
|
52
55
|
config_param :audience, :string, default: ""
|
|
53
56
|
|
|
@@ -112,11 +115,12 @@ class Fluent::Plugin::HTTPOutput < Fluent::Plugin::Output
|
|
|
112
115
|
config = conf.elements(name: 'storage').first
|
|
113
116
|
@storage = storage_create(usage: 'jwt_token', conf: config, default_type: 'local')
|
|
114
117
|
|
|
115
|
-
|
|
118
|
+
unless @config_file.empty?
|
|
116
119
|
creds = File.read(@config_file)
|
|
117
120
|
parsed = Yajl::Parser.new.parse(StringIO.new(creds))
|
|
118
121
|
@client_id = parsed.fetch("client_id", @client_id)
|
|
119
122
|
@client_secret = parsed.fetch("client_secret", @client_secret)
|
|
123
|
+
@entity_secret = parsed.fetch("entity_secret", @entity_secret)
|
|
120
124
|
@audience = parsed.fetch("audience", @audience)
|
|
121
125
|
@auth0_cert = parsed.fetch("auth0_cert", @auth0_cert)
|
|
122
126
|
@auth0_cert_file = parsed.fetch("auth0_cert", @auth0_cert_file)
|
|
@@ -127,17 +131,17 @@ class Fluent::Plugin::HTTPOutput < Fluent::Plugin::Output
|
|
|
127
131
|
@auth0_cert = File.read(@auth0_cert_file)
|
|
128
132
|
end
|
|
129
133
|
|
|
130
|
-
if @client_id.empty? &&
|
|
131
|
-
@client_secret.empty? &&
|
|
132
|
-
@audience.empty? &&
|
|
133
|
-
@auth0_cert.empty? &&
|
|
134
|
+
if @client_id.empty? &&
|
|
135
|
+
@client_secret.empty? &&
|
|
136
|
+
@audience.empty? &&
|
|
137
|
+
@auth0_cert.empty? &&
|
|
134
138
|
@auth0_domain.empty?
|
|
135
139
|
params = "client_id, client_secret, audience, auth0_cert and auth0_domain"
|
|
136
|
-
|
|
140
|
+
raise Fluent::ConfigError, "Missing configuration. Either specify a config_file or set the #{params} parameters"
|
|
137
141
|
end
|
|
138
142
|
|
|
139
143
|
if @endpoint_url.empty?
|
|
140
|
-
@endpoint_url = "https
|
|
144
|
+
@endpoint_url = "https://#{@auth0_domain.sub("auth", "logs")}"
|
|
141
145
|
log.info "Using logs endpoint #{@endpoint_url}"
|
|
142
146
|
end
|
|
143
147
|
|
|
@@ -207,12 +211,13 @@ class Fluent::Plugin::HTTPOutput < Fluent::Plugin::Output
|
|
|
207
211
|
url = "https://" + @auth0_domain + "/oauth/token"
|
|
208
212
|
uri = URI.parse(url)
|
|
209
213
|
req = Net::HTTP::Post.new(uri.to_s)
|
|
210
|
-
payload = {
|
|
214
|
+
payload = {
|
|
211
215
|
"client_id" => @client_id,
|
|
212
216
|
"client_secret" => @client_secret,
|
|
213
217
|
"audience" => @audience,
|
|
214
218
|
"grant_type" => "client_credentials"
|
|
215
219
|
}
|
|
220
|
+
payload["entity_secret"] = @entity_secret if @entity_secret
|
|
216
221
|
set_json_body(req, payload)
|
|
217
222
|
res = https(uri).request(req)
|
|
218
223
|
case res
|
|
@@ -281,8 +286,8 @@ class Fluent::Plugin::HTTPOutput < Fluent::Plugin::Output
|
|
|
281
286
|
end
|
|
282
287
|
|
|
283
288
|
def send_request(req, uri)
|
|
284
|
-
is_rate_limited = (@rate_limit_msec != 0
|
|
285
|
-
if is_rate_limited
|
|
289
|
+
is_rate_limited = (@rate_limit_msec != 0 && ! @last_request_time.nil?)
|
|
290
|
+
if is_rate_limited && ((Time.now.to_f - @last_request_time) * 1000.0 < @rate_limit_msec)
|
|
286
291
|
log.info('Dropped request due to rate limiting')
|
|
287
292
|
return
|
|
288
293
|
end
|
|
@@ -308,7 +313,7 @@ class Fluent::Plugin::HTTPOutput < Fluent::Plugin::Output
|
|
|
308
313
|
log.warn "Net::HTTP.#{req.method.capitalize} raises exception: #{e.class}, '#{e.message}'"
|
|
309
314
|
raise e if @raise_on_error
|
|
310
315
|
else
|
|
311
|
-
unless res
|
|
316
|
+
unless res && res.is_a?(Net::HTTPSuccess)
|
|
312
317
|
res_summary = if res
|
|
313
318
|
"#{res.code} #{res.message} #{res.body}"
|
|
314
319
|
else
|
data/run_test.rb
ADDED
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fluent-plugin-out-kivera
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tyler Matheson
|
|
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
|
|
@@ -103,30 +102,30 @@ dependencies:
|
|
|
103
102
|
description: A Fluentd output plugin for sending Kivera proxy logs to the Kivera log
|
|
104
103
|
ingestion service
|
|
105
104
|
email:
|
|
106
|
-
-
|
|
105
|
+
- tyler@kivera.io
|
|
107
106
|
executables: []
|
|
108
107
|
extensions: []
|
|
109
108
|
extra_rdoc_files: []
|
|
110
109
|
files:
|
|
111
|
-
- ".github/workflows/
|
|
112
|
-
- ".github/workflows/macos.yml"
|
|
110
|
+
- ".github/workflows/test.yml"
|
|
113
111
|
- ".gitignore"
|
|
114
112
|
- CHANGELOG.md
|
|
115
113
|
- Gemfile
|
|
116
114
|
- ISSUE_TEMPLATE.md
|
|
117
115
|
- LICENSE.txt
|
|
116
|
+
- Makefile
|
|
118
117
|
- README.md
|
|
119
118
|
- Rakefile
|
|
120
119
|
- fluent-plugin-out-kivera.gemspec
|
|
121
120
|
- lib/fluent/plugin/out_kivera.rb
|
|
122
121
|
- lib/fluent/test/http_output_test.rb
|
|
122
|
+
- run_test.rb
|
|
123
123
|
- test/plugin/script/plugin/formatter_test.rb
|
|
124
124
|
- test/plugin/test_out_kivera.rb
|
|
125
125
|
homepage: https://github.com/kivera-io/fluent-plugin-out-kivera
|
|
126
126
|
licenses:
|
|
127
127
|
- Apache-2.0
|
|
128
128
|
metadata: {}
|
|
129
|
-
post_install_message:
|
|
130
129
|
rdoc_options: []
|
|
131
130
|
require_paths:
|
|
132
131
|
- lib
|
|
@@ -141,8 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
141
140
|
- !ruby/object:Gem::Version
|
|
142
141
|
version: '0'
|
|
143
142
|
requirements: []
|
|
144
|
-
rubygems_version:
|
|
145
|
-
signing_key:
|
|
143
|
+
rubygems_version: 4.0.3
|
|
146
144
|
specification_version: 4
|
|
147
145
|
summary: Fluentd plugin for Kivera
|
|
148
146
|
test_files:
|
data/.github/workflows/linux.yml
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
name: Testing on Ubuntu
|
|
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.4', '2.5', '2.6', '2.7' ]
|
|
12
|
-
os:
|
|
13
|
-
- ubuntu-latest
|
|
14
|
-
name: Ruby ${{ matrix.ruby }} unit testing on ${{ matrix.os }}
|
|
15
|
-
steps:
|
|
16
|
-
- uses: actions/checkout@v2
|
|
17
|
-
- uses: ruby/setup-ruby@v1
|
|
18
|
-
with:
|
|
19
|
-
ruby-version: ${{ matrix.ruby }}
|
|
20
|
-
- name: unit testing
|
|
21
|
-
env:
|
|
22
|
-
CI: true
|
|
23
|
-
run: |
|
|
24
|
-
gem install bundler rake
|
|
25
|
-
bundle install --jobs 4 --retry 3
|
|
26
|
-
bundle exec rake test
|
data/.github/workflows/macos.yml
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
name: Testing on macOS
|
|
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.4', '2.5', '2.6', '2.7' ]
|
|
12
|
-
os:
|
|
13
|
-
- macOS-latest
|
|
14
|
-
name: Ruby ${{ matrix.ruby }} unit testing on ${{ matrix.os }}
|
|
15
|
-
steps:
|
|
16
|
-
- uses: actions/checkout@v2
|
|
17
|
-
- uses: ruby/setup-ruby@v1
|
|
18
|
-
with:
|
|
19
|
-
ruby-version: ${{ matrix.ruby }}
|
|
20
|
-
- name: unit testing
|
|
21
|
-
env:
|
|
22
|
-
CI: true
|
|
23
|
-
run: |
|
|
24
|
-
gem install bundler rake
|
|
25
|
-
bundle install --jobs 4 --retry 3
|
|
26
|
-
bundle exec rake test
|