fluent-plugin-logdna 0.2.3 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +30 -23
- data/README.md +14 -11
- data/fluent-plugin-logdna.gemspec +1 -1
- data/lib/fluent/plugin/out_logdna.rb +18 -1
- data/test/helper.rb +8 -0
- data/test/plugin/test_out_logdna.rb +110 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7dc5c3a579927d59c9a9705bd5ceec17d5a6dc3d8964d1639dd51afb23eaca80
|
4
|
+
data.tar.gz: 2519afb42481d5840bd11b5d579637e4ea55008dc89996421013185d76439374
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 511d77f656a7584723954052a7f4c0e70b39f8115f88cbfff2369b1d9e7388fac35242ff9b52a5e0b6b2292e73c757a3efb1025833bfd6b9a96dd9ef1437fad5
|
7
|
+
data.tar.gz: c1058ffb07ab69ad383c3b1d8015aaf912ebe3d0632c612c6e63d2ba41b75c6b930fa03f8f4a415c066501bbf4ab38f900f8728b9d630cf41bee002f5b8f6b2c
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,30 +1,32 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fluent-plugin-logdna (0.
|
4
|
+
fluent-plugin-logdna (0.3.1)
|
5
5
|
fluentd (>= 0.12.0, < 2)
|
6
6
|
http (~> 2.0, >= 2.0.3)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
addressable (2.
|
12
|
-
public_suffix (>= 2.0.2, <
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
addressable (2.7.0)
|
12
|
+
public_suffix (>= 2.0.2, < 5.0)
|
13
|
+
concurrent-ruby (1.1.6)
|
14
|
+
cool.io (1.6.0)
|
15
|
+
crack (0.4.3)
|
16
|
+
safe_yaml (~> 1.0.0)
|
17
|
+
domain_name (0.5.20190701)
|
16
18
|
unf (>= 0.0.5, < 1.0.0)
|
17
|
-
fluentd (1.
|
19
|
+
fluentd (1.11.1)
|
18
20
|
cool.io (>= 1.4.5, < 2.0.0)
|
19
|
-
dig_rb (~> 1.0.0)
|
20
21
|
http_parser.rb (>= 0.5.1, < 0.7.0)
|
21
|
-
msgpack (>=
|
22
|
+
msgpack (>= 1.3.1, < 2.0.0)
|
22
23
|
serverengine (>= 2.0.4, < 3.0.0)
|
23
24
|
sigdump (~> 0.2.2)
|
24
|
-
strptime (
|
25
|
-
tzinfo (
|
25
|
+
strptime (>= 0.2.2, < 1.0.0)
|
26
|
+
tzinfo (>= 1.0, < 3.0)
|
26
27
|
tzinfo-data (~> 1.0)
|
27
28
|
yajl-ruby (~> 1.0)
|
29
|
+
hashdiff (1.0.1)
|
28
30
|
http (2.2.2)
|
29
31
|
addressable (~> 2.3)
|
30
32
|
http-cookie (~> 1.0)
|
@@ -34,22 +36,26 @@ GEM
|
|
34
36
|
domain_name (~> 0.5)
|
35
37
|
http-form_data (1.0.3)
|
36
38
|
http_parser.rb (0.6.0)
|
37
|
-
msgpack (1.
|
38
|
-
public_suffix (
|
39
|
-
rake (12.3.
|
40
|
-
|
39
|
+
msgpack (1.3.3)
|
40
|
+
public_suffix (4.0.3)
|
41
|
+
rake (12.3.3)
|
42
|
+
safe_yaml (1.0.5)
|
43
|
+
serverengine (2.2.1)
|
41
44
|
sigdump (~> 0.2.2)
|
42
45
|
sigdump (0.2.4)
|
43
|
-
strptime (0.
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
tzinfo-data (1.2017.3)
|
46
|
+
strptime (0.2.4)
|
47
|
+
tzinfo (2.0.2)
|
48
|
+
concurrent-ruby (~> 1.0)
|
49
|
+
tzinfo-data (1.2020.1)
|
48
50
|
tzinfo (>= 1.0.0)
|
49
51
|
unf (0.1.4)
|
50
52
|
unf_ext
|
51
|
-
unf_ext (0.0.7.
|
52
|
-
|
53
|
+
unf_ext (0.0.7.7)
|
54
|
+
webmock (3.8.3)
|
55
|
+
addressable (>= 2.3.6)
|
56
|
+
crack (>= 0.3.2)
|
57
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
58
|
+
yajl-ruby (1.4.1)
|
53
59
|
|
54
60
|
PLATFORMS
|
55
61
|
ruby
|
@@ -58,6 +64,7 @@ DEPENDENCIES
|
|
58
64
|
bundler (~> 1.16)
|
59
65
|
fluent-plugin-logdna!
|
60
66
|
rake (~> 12.3)
|
67
|
+
webmock
|
61
68
|
|
62
69
|
BUNDLED WITH
|
63
|
-
1.
|
70
|
+
1.17.2
|
data/README.md
CHANGED
@@ -9,9 +9,9 @@ Using fluent-plugin-logdna, you can send the logs you collect with Fluentd to Lo
|
|
9
9
|
* Install [Fluentd](http://www.fluentd.org/download)
|
10
10
|
* Alternative install if using fluentd package manager (td-agent): `td-agent-gem install fluent-plugin-logdna`
|
11
11
|
* Add the contents below to `/etc/fluent/fluent.conf`. For td-agent, use `/etc/td-agent/td-agent.conf`:
|
12
|
-
* Alternative install without td-agent is: `gem install fluent-plugin-logdna`
|
12
|
+
* Alternative install without td-agent is: `gem install fluent-plugin-logdna`
|
13
13
|
|
14
|
-
~~~~~
|
14
|
+
~~~~~configuration
|
15
15
|
<match **>
|
16
16
|
@type logdna
|
17
17
|
api_key xxxxxxxxxxxxxxxxxxxxxxxxxxx # paste your api key here (required)
|
@@ -20,10 +20,12 @@ Using fluent-plugin-logdna, you can send the logs you collect with Fluentd to Lo
|
|
20
20
|
#mac C0:FF:EE:C0:FF:EE # optional mac address
|
21
21
|
#ip 127.0.0.1 # optional ip address
|
22
22
|
#tags web,dev # optional tags
|
23
|
+
request_timeout 30000 ms # optional timeout for upload request, supports seconds (s, default) and milliseconds (ms) suffixes, default 30 seconds
|
23
24
|
buffer_chunk_limit 1m # do not increase past 8m (8MB) or your logs will be rejected by our server.
|
24
25
|
flush_at_shutdown true # only needed with file buffer
|
25
26
|
</match>
|
26
27
|
~~~~~
|
28
|
+
|
27
29
|
* Restart fluentd to pick up the configuration changes.
|
28
30
|
* `sudo /etc/init.d/td-agent stop`
|
29
31
|
* `sudo /etc/init.d/td-agent start`
|
@@ -31,44 +33,45 @@ Using fluent-plugin-logdna, you can send the logs you collect with Fluentd to Lo
|
|
31
33
|
### Recommended Configuration Parameters
|
32
34
|
|
33
35
|
* buffer_type
|
34
|
-
|
36
|
+
* We recommend setting this to memory for development and file for production (file setting requires a buffer_path).
|
35
37
|
* buffer_queue_limit, buffer_chunk_limit
|
36
|
-
|
38
|
+
* We do not recommend increasing buffer_chunk_limit past 8MB.
|
37
39
|
* flush_interval
|
38
|
-
|
40
|
+
* Default is 60s. We recommend keeping this well above 5s.
|
39
41
|
* retry_wait, max_retry_wait, retry_limit, disable_retry_limit
|
40
|
-
|
42
|
+
* We recommend increasing these values if you are encountering problems.
|
41
43
|
|
42
44
|
### Options
|
43
45
|
|
44
46
|
* App name and log level can also be provided on a line-by-line basis over JSON:
|
45
47
|
* `_app` and `level` will override the config
|
46
48
|
|
47
|
-
If you don't have a LogDNA account, you can create one on https://logdna.com or if you're on macOS w/[Homebrew](https://brew.sh) installed:
|
49
|
+
If you don't have a LogDNA account, you can create one on [https://logdna.com](https://logdna.com) or if you're on macOS w/[Homebrew](https://brew.sh) installed:
|
48
50
|
|
49
|
-
|
51
|
+
~~~~~bash
|
50
52
|
brew cask install logdna-cli
|
51
53
|
logdna register <email>
|
52
54
|
# now paste the api key above
|
53
|
-
|
55
|
+
~~~~~
|
54
56
|
|
55
57
|
### LogDNA Pay-per-gig Pricing
|
56
58
|
|
57
59
|
Our [paid plans](https://logdna.com/#pricing) start at $1.25/GB per month, pay for what you use / no fixed data buckets / all paid plans include all features.
|
58
60
|
|
59
61
|
## Building a debian package for td-agent
|
62
|
+
|
60
63
|
If you use td-agent you can build a debian package instead of installing via
|
61
64
|
td-agent-gem. This requires that td-agent is already installed and that you've
|
62
65
|
installed [fpm](http://fpm.readthedocs.io/en/latest/index.html). Then just run
|
63
66
|
`make` in your git directory.
|
64
67
|
|
65
|
-
|
68
|
+
~~~~~bash
|
66
69
|
gem install --no-ri --no-rdoc fpm
|
67
70
|
git clone https://github.com/logdna/fluent-plugin-logdna
|
68
71
|
cd fluent-plugin-logdna
|
69
72
|
make
|
70
73
|
sudo dpkg -i fluent-plugin-logdna*.deb
|
71
|
-
|
74
|
+
~~~~~
|
72
75
|
|
73
76
|
## Additional Options
|
74
77
|
|
@@ -14,10 +14,26 @@ module Fluent
|
|
14
14
|
config_param :app, :string, default: nil
|
15
15
|
config_param :file, :string, default: nil
|
16
16
|
config_param :ingester_domain, :string, default: 'https://logs.logdna.com'
|
17
|
+
config_param :request_timeout, :string, default: '30'
|
17
18
|
|
18
19
|
def configure(conf)
|
19
20
|
super
|
20
21
|
@host = conf['hostname']
|
22
|
+
|
23
|
+
# make these two variables globals
|
24
|
+
timeout_unit_map = { s: 1.0, ms: 0.001 }
|
25
|
+
timeout_regex = Regexp.new("^([0-9]+)\s*(#{timeout_unit_map.keys.join("|")})$")
|
26
|
+
|
27
|
+
# this section goes into this part of the code
|
28
|
+
num_component = 30.0
|
29
|
+
unit_component = 's'
|
30
|
+
|
31
|
+
timeout_regex.match(@request_timeout) do |match|
|
32
|
+
num_component = match[1].to_f
|
33
|
+
unit_component = match[2]
|
34
|
+
end
|
35
|
+
|
36
|
+
@request_timeout = num_component * timeout_unit_map[unit_component.to_sym]
|
21
37
|
end
|
22
38
|
|
23
39
|
def start
|
@@ -84,7 +100,8 @@ module Fluent
|
|
84
100
|
url = "/logs/ingest?hostname=#{@host}&mac=#{@mac}&ip=#{@ip}&now=#{now}&tags=#{@tags}"
|
85
101
|
@ingester.headers('apikey' => @api_key,
|
86
102
|
'content-type' => 'application/json')
|
87
|
-
|
103
|
+
.timeout(connect: @request_timeout, write: @request_timeout, read: @request_timeout)
|
104
|
+
.post(url, json: body)
|
88
105
|
end
|
89
106
|
end
|
90
107
|
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.expand_path("../../", __FILE__))
|
2
|
+
require "test-unit"
|
3
|
+
require "fluent/test"
|
4
|
+
require "fluent/test/driver/output"
|
5
|
+
require "fluent/test/helpers"
|
6
|
+
|
7
|
+
Test::Unit::TestCase.include(Fluent::Test::Helpers)
|
8
|
+
Test::Unit::TestCase.extend(Fluent::Test::Helpers)
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# https://docs.fluentd.org/plugin-development/api-plugin-output#how-to-write-tests
|
2
|
+
|
3
|
+
require_relative '../helper'
|
4
|
+
require 'fluent/test/driver/output'
|
5
|
+
require 'fluent/plugin/out_stdout'
|
6
|
+
require 'fluent/plugin/input'
|
7
|
+
require 'webmock/test_unit'
|
8
|
+
include WebMock::API
|
9
|
+
|
10
|
+
require 'lib/fluent/plugin/out_logdna.rb'
|
11
|
+
|
12
|
+
class LogdnaOutputTest < Test::Unit::TestCase
|
13
|
+
def setup
|
14
|
+
Fluent::Test.setup
|
15
|
+
|
16
|
+
stub_request(:post, /logs.logdna.com\/logs\/ingest/)
|
17
|
+
end
|
18
|
+
|
19
|
+
# default configuration for tests
|
20
|
+
CONFIG = %[
|
21
|
+
api_key this-is-my-key
|
22
|
+
hostname "localhost"
|
23
|
+
app my_app
|
24
|
+
mac C0:FF:EE:C0:FF:EE
|
25
|
+
ip 127.0.0.1
|
26
|
+
tags "my-tag"
|
27
|
+
]
|
28
|
+
|
29
|
+
def create_driver(conf = CONFIG)
|
30
|
+
Fluent::Test::Driver::Output.new(Fluent::LogDNAOutput).configure(conf)
|
31
|
+
end
|
32
|
+
|
33
|
+
sub_test_case 'configuration' do
|
34
|
+
test 'instantiate the plugin and check default config values' do
|
35
|
+
d = create_driver
|
36
|
+
time = event_time
|
37
|
+
|
38
|
+
# check defaults
|
39
|
+
assert_equal 'https://logs.logdna.com', d.instance.ingester_domain
|
40
|
+
assert_equal 30, d.instance.request_timeout
|
41
|
+
end
|
42
|
+
|
43
|
+
test 'instantiate the plugin and check setting config values' do
|
44
|
+
conf = %[
|
45
|
+
api_key this-is-my-key
|
46
|
+
hostname "localhost"
|
47
|
+
app my_app
|
48
|
+
mac C0:FF:EE:C0:FF:EE
|
49
|
+
ip 127.0.0.1
|
50
|
+
tags "my-tag"
|
51
|
+
request_timeout 17s
|
52
|
+
]
|
53
|
+
|
54
|
+
d = create_driver(conf)
|
55
|
+
|
56
|
+
# check set config values
|
57
|
+
assert_equal 'my-tag', d.instance.tags
|
58
|
+
assert_equal 17, d.instance.request_timeout
|
59
|
+
end
|
60
|
+
|
61
|
+
test 'instantiate the plugin with ms request_timeout value' do
|
62
|
+
|
63
|
+
conf = %[
|
64
|
+
api_key this-is-my-key
|
65
|
+
hostname "localhost"
|
66
|
+
app my_app
|
67
|
+
mac C0:FF:EE:C0:FF:EE
|
68
|
+
ip 127.0.0.1
|
69
|
+
tags "my-tag"
|
70
|
+
request_timeout 17000 ms
|
71
|
+
]
|
72
|
+
|
73
|
+
d = create_driver(conf)
|
74
|
+
|
75
|
+
# check set config values
|
76
|
+
assert_equal 17, d.instance.request_timeout
|
77
|
+
end
|
78
|
+
|
79
|
+
test 'instantiate the plugin with nonesense request_timeout value' do
|
80
|
+
|
81
|
+
conf = %[
|
82
|
+
api_key this-is-my-key
|
83
|
+
hostname "localhost"
|
84
|
+
app my_app
|
85
|
+
mac C0:FF:EE:C0:FF:EE
|
86
|
+
ip 127.0.0.1
|
87
|
+
tags "my-tag"
|
88
|
+
request_timeout "asdf ms"
|
89
|
+
]
|
90
|
+
|
91
|
+
d = create_driver(conf)
|
92
|
+
|
93
|
+
# check set config values
|
94
|
+
assert_equal 30, d.instance.request_timeout
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
test 'simple #write' do
|
99
|
+
d = create_driver
|
100
|
+
time = event_time
|
101
|
+
|
102
|
+
d.run do
|
103
|
+
d.feed("output.test", time, {'foo' => 'bar', 'message' => 'myLine'})
|
104
|
+
d.feed("output.test", time, {'foo' => 'bar', 'message' => 'myLine'})
|
105
|
+
end
|
106
|
+
|
107
|
+
assert_equal(2, d.formatted.size)
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-logdna
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edwin Lai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,8 @@ files:
|
|
80
80
|
- Rakefile
|
81
81
|
- fluent-plugin-logdna.gemspec
|
82
82
|
- lib/fluent/plugin/out_logdna.rb
|
83
|
+
- test/helper.rb
|
84
|
+
- test/plugin/test_out_logdna.rb
|
83
85
|
homepage: https://github.com/logdna/fluent-plugin-logdna
|
84
86
|
licenses:
|
85
87
|
- MIT
|