fluent-plugin-logdna 0.1.5 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +6 -0
- data/Gemfile.lock +70 -0
- data/Makefile +62 -0
- data/README.md +63 -11
- data/Rakefile +48 -0
- data/fluent-plugin-logdna.gemspec +2 -1
- data/lib/fluent/plugin/out_logdna.rb +38 -18
- data/test/helper.rb +8 -0
- data/test/plugin/test_out_logdna.rb +110 -0
- metadata +35 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
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
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
fluent-plugin-logdna (0.3.1)
|
5
|
+
fluentd (>= 0.12.0, < 2)
|
6
|
+
http (~> 2.0, >= 2.0.3)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
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)
|
18
|
+
unf (>= 0.0.5, < 1.0.0)
|
19
|
+
fluentd (1.11.1)
|
20
|
+
cool.io (>= 1.4.5, < 2.0.0)
|
21
|
+
http_parser.rb (>= 0.5.1, < 0.7.0)
|
22
|
+
msgpack (>= 1.3.1, < 2.0.0)
|
23
|
+
serverengine (>= 2.0.4, < 3.0.0)
|
24
|
+
sigdump (~> 0.2.2)
|
25
|
+
strptime (>= 0.2.2, < 1.0.0)
|
26
|
+
tzinfo (>= 1.0, < 3.0)
|
27
|
+
tzinfo-data (~> 1.0)
|
28
|
+
yajl-ruby (~> 1.0)
|
29
|
+
hashdiff (1.0.1)
|
30
|
+
http (2.2.2)
|
31
|
+
addressable (~> 2.3)
|
32
|
+
http-cookie (~> 1.0)
|
33
|
+
http-form_data (~> 1.0.1)
|
34
|
+
http_parser.rb (~> 0.6.0)
|
35
|
+
http-cookie (1.0.3)
|
36
|
+
domain_name (~> 0.5)
|
37
|
+
http-form_data (1.0.3)
|
38
|
+
http_parser.rb (0.6.0)
|
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)
|
44
|
+
sigdump (~> 0.2.2)
|
45
|
+
sigdump (0.2.4)
|
46
|
+
strptime (0.2.4)
|
47
|
+
tzinfo (2.0.2)
|
48
|
+
concurrent-ruby (~> 1.0)
|
49
|
+
tzinfo-data (1.2020.1)
|
50
|
+
tzinfo (>= 1.0.0)
|
51
|
+
unf (0.1.4)
|
52
|
+
unf_ext
|
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)
|
59
|
+
|
60
|
+
PLATFORMS
|
61
|
+
ruby
|
62
|
+
|
63
|
+
DEPENDENCIES
|
64
|
+
bundler (~> 1.16)
|
65
|
+
fluent-plugin-logdna!
|
66
|
+
rake (~> 12.3)
|
67
|
+
webmock
|
68
|
+
|
69
|
+
BUNDLED WITH
|
70
|
+
1.17.2
|
data/Makefile
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# Generate a debian package for fluent-plugin-logdna
|
2
|
+
#
|
3
|
+
# This assumes that you have the td-agent package already installed
|
4
|
+
# https://docs.fluentd.org/v1.0/articles/install-by-deb
|
5
|
+
#
|
6
|
+
# The package is created with fpm (it does not necessarily need to be
|
7
|
+
# installed into the td-agent embedded ruby). To install fpm run:
|
8
|
+
# $ sudo gem install --no-ri --no-rdoc fpm
|
9
|
+
#
|
10
|
+
# The td-agent package installs an embedded ruby distribution in
|
11
|
+
# /opt/td-agent/embedded which has its own list of gems. Our built package
|
12
|
+
# cannot conflict with those gems so we will elect to bundle a subset of gems
|
13
|
+
# with our package. This may conflict with other packages and this package is
|
14
|
+
# not intended to be a general purpose package.
|
15
|
+
|
16
|
+
# Paths to td-agent specific versions of bundle and gem
|
17
|
+
BUNDLE=/opt/td-agent/embedded/bin/bundle
|
18
|
+
GEM=/opt/td-agent/embedded/bin/gem
|
19
|
+
RUBY=/opt/td-agent/embedded/bin/ruby
|
20
|
+
RAKE=/opt/td-agent/embedded/bin/rake
|
21
|
+
FPM=fpm
|
22
|
+
|
23
|
+
# Bundle will unpack gems into the bundle directory
|
24
|
+
BUNDLE_DIR=./vendor/bundle
|
25
|
+
# Bundle will save gems in the cache directory
|
26
|
+
CACHE_DIR=./vendor/cache
|
27
|
+
PKG_DIR=pkg
|
28
|
+
# Bundle will store settings and locks in the dot_bundle directory
|
29
|
+
DOT_BUNDLE=./.bundle
|
30
|
+
|
31
|
+
GEMSPEC := ${wildcard *.gemspec}
|
32
|
+
NAME := ${shell $(RUBY) -e 'puts Gem::Specification::load("$(GEMSPEC)").name'}
|
33
|
+
VERSION := ${shell $(RUBY) -e 'puts Gem::Specification::load("$(GEMSPEC)").version.to_s'}
|
34
|
+
GEMFILE := ${shell $(RUBY) -e 'puts Gem::Specification::load("$(GEMSPEC)").file_name'}
|
35
|
+
DEBFILE := $(NAME)_$(VERSION)_all.deb
|
36
|
+
|
37
|
+
all: $(DEBFILE)
|
38
|
+
|
39
|
+
$(BUNDLE_DIR): Gemfile.lock
|
40
|
+
$(BUNDLE) install --frozen --path $(BUNDLE_DIR)
|
41
|
+
|
42
|
+
$(CACHE_DIR): $(BUNDLE_DIR) Gemfile.lock
|
43
|
+
$(BUNDLE) package --no-install
|
44
|
+
|
45
|
+
$(GEMFILE): $(BUNDLE_DIR)
|
46
|
+
$(BUNDLE) exec $(GEM) build -V $(GEMSPEC)
|
47
|
+
|
48
|
+
$(DEBFILE): $(GEMFILE) $(CACHE_DIR)
|
49
|
+
$(BUNDLE) exec $(RAKE) gemdep:minimal
|
50
|
+
$(FPM) --input-type gem --output-type deb \
|
51
|
+
--no-auto-depends \
|
52
|
+
--no-gem-fix-name \
|
53
|
+
--gem-gem $(GEM) \
|
54
|
+
--depends 'td-agent > 2' \
|
55
|
+
--deb-build-depends 'td-agent > 2' \
|
56
|
+
pkg/*.gem $(GEMFILE)
|
57
|
+
|
58
|
+
clean:
|
59
|
+
-$(BUNDLE) exec $(RAKE) clobber
|
60
|
+
rm -rf $(BUNDLE_DIR) $(CACHE_DIR) $(DOT_BUNDLE) $(GEMFILE) $(DEBFILE)
|
61
|
+
|
62
|
+
.PHONY: all clean
|
data/README.md
CHANGED
@@ -7,22 +7,74 @@ Using fluent-plugin-logdna, you can send the logs you collect with Fluentd to Lo
|
|
7
7
|
## Instructions
|
8
8
|
|
9
9
|
* Install [Fluentd](http://www.fluentd.org/download)
|
10
|
-
*
|
11
|
-
*
|
12
|
-
*
|
10
|
+
* Alternative install if using fluentd package manager (td-agent): `td-agent-gem install fluent-plugin-logdna`
|
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`
|
13
13
|
|
14
|
-
~~~~~
|
15
|
-
<match
|
14
|
+
~~~~~configuration
|
15
|
+
<match **>
|
16
16
|
@type logdna
|
17
|
-
api_key
|
18
|
-
hostname
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
api_key xxxxxxxxxxxxxxxxxxxxxxxxxxx # paste your api key here (required)
|
18
|
+
hostname "#{Socket.gethostname}" # your hostname (required)
|
19
|
+
app my_app # replace with your app name
|
20
|
+
#mac C0:FF:EE:C0:FF:EE # optional mac address
|
21
|
+
#ip 127.0.0.1 # optional ip address
|
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
|
24
|
+
buffer_chunk_limit 1m # do not increase past 8m (8MB) or your logs will be rejected by our server.
|
25
|
+
flush_at_shutdown true # only needed with file buffer
|
22
26
|
</match>
|
23
27
|
~~~~~
|
28
|
+
|
24
29
|
* Restart fluentd to pick up the configuration changes.
|
30
|
+
* `sudo /etc/init.d/td-agent stop`
|
31
|
+
* `sudo /etc/init.d/td-agent start`
|
32
|
+
|
33
|
+
### Recommended Configuration Parameters
|
34
|
+
|
35
|
+
* buffer_type
|
36
|
+
* We recommend setting this to memory for development and file for production (file setting requires a buffer_path).
|
37
|
+
* buffer_queue_limit, buffer_chunk_limit
|
38
|
+
* We do not recommend increasing buffer_chunk_limit past 8MB.
|
39
|
+
* flush_interval
|
40
|
+
* Default is 60s. We recommend keeping this well above 5s.
|
41
|
+
* retry_wait, max_retry_wait, retry_limit, disable_retry_limit
|
42
|
+
* We recommend increasing these values if you are encountering problems.
|
43
|
+
|
44
|
+
### Options
|
45
|
+
|
46
|
+
* App name and log level can also be provided on a line-by-line basis over JSON:
|
47
|
+
* `_app` and `level` will override the config
|
48
|
+
|
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:
|
50
|
+
|
51
|
+
~~~~~bash
|
52
|
+
brew cask install logdna-cli
|
53
|
+
logdna register <email>
|
54
|
+
# now paste the api key above
|
55
|
+
~~~~~
|
56
|
+
|
57
|
+
### LogDNA Pay-per-gig Pricing
|
58
|
+
|
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.
|
60
|
+
|
61
|
+
## Building a debian package for td-agent
|
62
|
+
|
63
|
+
If you use td-agent you can build a debian package instead of installing via
|
64
|
+
td-agent-gem. This requires that td-agent is already installed and that you've
|
65
|
+
installed [fpm](http://fpm.readthedocs.io/en/latest/index.html). Then just run
|
66
|
+
`make` in your git directory.
|
67
|
+
|
68
|
+
~~~~~bash
|
69
|
+
gem install --no-ri --no-rdoc fpm
|
70
|
+
git clone https://github.com/logdna/fluent-plugin-logdna
|
71
|
+
cd fluent-plugin-logdna
|
72
|
+
make
|
73
|
+
sudo dpkg -i fluent-plugin-logdna*.deb
|
74
|
+
~~~~~
|
75
|
+
|
76
|
+
## Additional Options
|
25
77
|
|
26
|
-
For advanced configuration options, refer to the [buffered output parameters documentation.](http://docs.fluentd.org/articles/output-plugin-overview#buffered-output-parameters)
|
78
|
+
For advanced configuration options, please refer to the [buffered output parameters documentation.](http://docs.fluentd.org/articles/output-plugin-overview#buffered-output-parameters)
|
27
79
|
|
28
80
|
Questions or concerns? Contact [support@logdna.com](mailto:support@logdna.com).
|
data/Rakefile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require "set"
|
2
|
+
|
3
|
+
# Directory to place gems to bundle with our main gem
|
4
|
+
PACKAGE_DIR = "pkg"
|
5
|
+
require "rake/clean"
|
6
|
+
CLOBBER.include PACKAGE_DIR
|
7
|
+
|
8
|
+
desc "Copies gem dependencies to the #{PACKAGE_DIR} folder"
|
9
|
+
task "gemdep" do
|
10
|
+
gem_copy gen_gem_list
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "Copies gem dependencies which don't overlap with td-agent to the #{PACKAGE_DIR} folder"
|
14
|
+
task "gemdep:minimal" do
|
15
|
+
MINIMAL_GEMS = %W[
|
16
|
+
unf_ext
|
17
|
+
unf
|
18
|
+
domain_name
|
19
|
+
http-cookie
|
20
|
+
http-form_data
|
21
|
+
http
|
22
|
+
]
|
23
|
+
gem_copy gen_gem_list MINIMAL_GEMS
|
24
|
+
end
|
25
|
+
|
26
|
+
def gen_gem_list(subset = [])
|
27
|
+
myself = Bundler.load_gemspec(Dir[File.join(Bundler::SharedHelpers.pwd, "{,*}.gemspec")].first)
|
28
|
+
to_pull = Set[]
|
29
|
+
Bundler.locked_gems.specs.each do |spec|
|
30
|
+
next if spec.name == myself.name
|
31
|
+
if subset.empty?
|
32
|
+
to_pull.add(spec)
|
33
|
+
else
|
34
|
+
if subset.include? spec.name
|
35
|
+
to_pull.add(spec)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
to_pull
|
40
|
+
end
|
41
|
+
|
42
|
+
# This assumes that bundle install has already been run (which populates
|
43
|
+
# Bundler.app_cache with the gems of dependencies).
|
44
|
+
def gem_copy(specs)
|
45
|
+
Bundler.mkdir_p PACKAGE_DIR
|
46
|
+
sources = specs.collect { |s| Bundler.app_cache.join "#{s.full_name}.gem" }
|
47
|
+
FileUtils.cp sources, PACKAGE_DIR, :verbose => true
|
48
|
+
end
|
@@ -3,7 +3,7 @@ require 'date'
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = 'fluent-plugin-logdna'
|
6
|
-
s.version = '0.1
|
6
|
+
s.version = '0.3.1'
|
7
7
|
s.date = Date.today.to_s
|
8
8
|
s.summary = 'LogDNA plugin for Fluentd'
|
9
9
|
s.description = 'Fluentd plugin for supplying output to LogDNA.'
|
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.files = `git ls-files -z`.split("\x0")
|
18
18
|
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
19
|
s.required_ruby_version = Gem::Requirement.new('>= 2.0.0')
|
20
|
+
s.add_development_dependency "bundler", "~> 1.16"
|
20
21
|
s.add_runtime_dependency 'fluentd', '>= 0.12.0', '< 2'
|
21
22
|
s.add_runtime_dependency 'http', '~> 2.0', '>= 2.0.3'
|
22
23
|
end
|
@@ -4,17 +4,36 @@ module Fluent
|
|
4
4
|
class LogDNAOutput < Fluent::BufferedOutput
|
5
5
|
Fluent::Plugin.register_output('logdna', self)
|
6
6
|
|
7
|
-
|
7
|
+
MAX_RETRIES = 5
|
8
8
|
|
9
9
|
config_param :api_key, :string, secret: true
|
10
10
|
config_param :hostname, :string
|
11
11
|
config_param :mac, :string, default: nil
|
12
|
+
config_param :tags, :string, default: nil
|
12
13
|
config_param :ip, :string, default: nil
|
13
14
|
config_param :app, :string, default: nil
|
15
|
+
config_param :file, :string, default: nil
|
16
|
+
config_param :ingester_domain, :string, default: 'https://logs.logdna.com'
|
17
|
+
config_param :request_timeout, :string, default: '30'
|
14
18
|
|
15
19
|
def configure(conf)
|
16
20
|
super
|
17
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]
|
18
37
|
end
|
19
38
|
|
20
39
|
def start
|
@@ -22,7 +41,9 @@ module Fluent
|
|
22
41
|
require 'json'
|
23
42
|
require 'base64'
|
24
43
|
require 'http'
|
25
|
-
|
44
|
+
HTTP.default_options = { :keep_alive_timeout => 60 }
|
45
|
+
@ingester = HTTP.persistent @ingester_domain
|
46
|
+
@requests = Queue.new
|
26
47
|
end
|
27
48
|
|
28
49
|
def shutdown
|
@@ -37,7 +58,8 @@ module Fluent
|
|
37
58
|
def write(chunk)
|
38
59
|
body = chunk_to_body(chunk)
|
39
60
|
response = send_request(body)
|
40
|
-
|
61
|
+
raise 'Encountered server error' if response.code >= 400
|
62
|
+
response.flush
|
41
63
|
end
|
42
64
|
|
43
65
|
private
|
@@ -47,7 +69,7 @@ module Fluent
|
|
47
69
|
|
48
70
|
chunk.msgpack_each do |(tag, time, record)|
|
49
71
|
line = gather_line_data(tag, time, record)
|
50
|
-
data << line
|
72
|
+
data << line unless line[:line].empty?
|
51
73
|
end
|
52
74
|
|
53
75
|
{ lines: data }
|
@@ -57,31 +79,29 @@ module Fluent
|
|
57
79
|
line = {
|
58
80
|
level: record['level'] || record['severity'] || tag.split('.').last,
|
59
81
|
timestamp: time,
|
60
|
-
line: record
|
82
|
+
line: record.to_json
|
61
83
|
}
|
84
|
+
# At least one of "file" or "app" is required.
|
85
|
+
line[:file] = record['file']
|
86
|
+
line[:file] ||= @file if @file
|
87
|
+
line.delete(:file) if line[:file].nil?
|
62
88
|
line[:app] = record['_app'] || record['app']
|
63
89
|
line[:app] ||= @app if @app
|
64
90
|
line.delete(:app) if line[:app].nil?
|
91
|
+
line[:env] = record['env']
|
92
|
+
line.delete(:env) if line[:env].nil?
|
93
|
+
line[:meta] = record['meta']
|
94
|
+
line.delete(:meta) if line[:meta].nil?
|
65
95
|
line
|
66
96
|
end
|
67
97
|
|
68
|
-
def handle(response)
|
69
|
-
if response.code >= 400
|
70
|
-
print "Error connecting to LogDNA ingester. \n"
|
71
|
-
print "Details: #{response}"
|
72
|
-
else
|
73
|
-
print "Success! #{response}"
|
74
|
-
end
|
75
|
-
|
76
|
-
response.flush
|
77
|
-
end
|
78
|
-
|
79
98
|
def send_request(body)
|
80
99
|
now = Time.now.to_i
|
81
|
-
url = "/logs/ingest?hostname=#{@host}&mac=#{@mac}&ip=#{@ip}&now=#{now}"
|
100
|
+
url = "/logs/ingest?hostname=#{@host}&mac=#{@mac}&ip=#{@ip}&now=#{now}&tags=#{@tags}"
|
82
101
|
@ingester.headers('apikey' => @api_key,
|
83
102
|
'content-type' => 'application/json')
|
84
|
-
|
103
|
+
.timeout(connect: @request_timeout, write: @request_timeout, read: @request_timeout)
|
104
|
+
.post(url, json: body)
|
85
105
|
end
|
86
106
|
end
|
87
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,53 +1,67 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-logdna
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
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:
|
11
|
+
date: 2020-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: fluentd
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
|
-
- -
|
31
|
+
- - ">="
|
18
32
|
- !ruby/object:Gem::Version
|
19
33
|
version: 0.12.0
|
20
|
-
- - <
|
34
|
+
- - "<"
|
21
35
|
- !ruby/object:Gem::Version
|
22
36
|
version: '2'
|
23
37
|
type: :runtime
|
24
38
|
prerelease: false
|
25
39
|
version_requirements: !ruby/object:Gem::Requirement
|
26
40
|
requirements:
|
27
|
-
- -
|
41
|
+
- - ">="
|
28
42
|
- !ruby/object:Gem::Version
|
29
43
|
version: 0.12.0
|
30
|
-
- - <
|
44
|
+
- - "<"
|
31
45
|
- !ruby/object:Gem::Version
|
32
46
|
version: '2'
|
33
47
|
- !ruby/object:Gem::Dependency
|
34
48
|
name: http
|
35
49
|
requirement: !ruby/object:Gem::Requirement
|
36
50
|
requirements:
|
37
|
-
- - ~>
|
51
|
+
- - "~>"
|
38
52
|
- !ruby/object:Gem::Version
|
39
53
|
version: '2.0'
|
40
|
-
- -
|
54
|
+
- - ">="
|
41
55
|
- !ruby/object:Gem::Version
|
42
56
|
version: 2.0.3
|
43
57
|
type: :runtime
|
44
58
|
prerelease: false
|
45
59
|
version_requirements: !ruby/object:Gem::Requirement
|
46
60
|
requirements:
|
47
|
-
- - ~>
|
61
|
+
- - "~>"
|
48
62
|
- !ruby/object:Gem::Version
|
49
63
|
version: '2.0'
|
50
|
-
- -
|
64
|
+
- - ">="
|
51
65
|
- !ruby/object:Gem::Version
|
52
66
|
version: 2.0.3
|
53
67
|
description: Fluentd plugin for supplying output to LogDNA.
|
@@ -56,12 +70,18 @@ executables: []
|
|
56
70
|
extensions: []
|
57
71
|
extra_rdoc_files: []
|
58
72
|
files:
|
59
|
-
- .gitignore
|
60
|
-
- .ruby-version
|
73
|
+
- ".gitignore"
|
74
|
+
- ".ruby-version"
|
75
|
+
- Gemfile
|
76
|
+
- Gemfile.lock
|
61
77
|
- LICENSE
|
78
|
+
- Makefile
|
62
79
|
- README.md
|
80
|
+
- Rakefile
|
63
81
|
- fluent-plugin-logdna.gemspec
|
64
82
|
- lib/fluent/plugin/out_logdna.rb
|
83
|
+
- test/helper.rb
|
84
|
+
- test/plugin/test_out_logdna.rb
|
65
85
|
homepage: https://github.com/logdna/fluent-plugin-logdna
|
66
86
|
licenses:
|
67
87
|
- MIT
|
@@ -72,17 +92,16 @@ require_paths:
|
|
72
92
|
- lib
|
73
93
|
required_ruby_version: !ruby/object:Gem::Requirement
|
74
94
|
requirements:
|
75
|
-
- -
|
95
|
+
- - ">="
|
76
96
|
- !ruby/object:Gem::Version
|
77
97
|
version: 2.0.0
|
78
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
99
|
requirements:
|
80
|
-
- -
|
100
|
+
- - ">="
|
81
101
|
- !ruby/object:Gem::Version
|
82
102
|
version: '0'
|
83
103
|
requirements: []
|
84
|
-
|
85
|
-
rubygems_version: 2.0.14.1
|
104
|
+
rubygems_version: 3.0.3
|
86
105
|
signing_key:
|
87
106
|
specification_version: 4
|
88
107
|
summary: LogDNA plugin for Fluentd
|