fluent-plugin-input-gelf 0.2.0 → 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/.travis.yml +23 -6
- data/fluent-plugin-input-gelf.gemspec +2 -2
- data/lib/fluent/plugin/in_gelf.rb +27 -41
- data/test/plugin/test_in_gelf.rb +8 -14
- data/test/test_helper.rb +1 -10
- metadata +12 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8f097e210aed3af36c1e2d4e69863ae9e7def76a8dc146b1d62142e7a468021d
|
4
|
+
data.tar.gz: 12fc71512e8cfd1a77bf061caf6857e2b8da1489a0050054dac7071a507ffb10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8811bb2fb2d6d81120d7007d7ca939fd065f22ae0d6ba41f6bd6279c74e8e3cc6926f7b82c441f73f33a784de3c965d59fc5f940721b344b0a36a5b80ef668fd
|
7
|
+
data.tar.gz: 04f05ae7694cadf96b89d6ed249e03d10228be6282cfff4652a0347414bd634b49222f62d472594594e1c77b4bc43be10b2894343ef406fe5a8831482be1ef81
|
data/.travis.yml
CHANGED
@@ -1,16 +1,33 @@
|
|
1
1
|
language: ruby
|
2
2
|
|
3
3
|
rvm:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
- 2.1
|
5
|
+
- 2.2
|
6
|
+
- 2.3
|
7
|
+
- 2.4
|
8
|
+
- 2.5
|
8
9
|
|
9
10
|
gemfile:
|
10
|
-
|
11
|
+
- Gemfile
|
11
12
|
|
12
13
|
branches:
|
13
14
|
only:
|
14
|
-
|
15
|
+
- master
|
16
|
+
# Tagged commits
|
17
|
+
- /^v\d+\.\d+(\.\d+)?(-\S*)?$/
|
15
18
|
|
16
19
|
script: bundle exec rake test
|
20
|
+
|
21
|
+
jobs:
|
22
|
+
include:
|
23
|
+
- stage: gem release
|
24
|
+
rvm: 2.3
|
25
|
+
script: echo "Deploying to rubygems.org ..."
|
26
|
+
deploy:
|
27
|
+
provider: rubygems
|
28
|
+
api_key:
|
29
|
+
secure: R06ICCYHjZ+bk+CocD+eZROiTsfDnmUlugdSIqND0f9Z+Vi8ALOZmIEhlpBvloRaOLU0pz3d9juj74vHMJ1boJN6Qgn+CtAGSDzesxm6vcd/AP87mEzAaJvvHRme7bNLy7gt1RvrmVzDjyOe2fF8kcVAz19bEArJ1rqBXeLiLY+fOPenCsWRNrOt2+yOH5qRgdFs+n2NQ6oQrDEq18uZJVQ74WnSyKGylIhPfXj+TcgMrDGJtxqWYmL+DeuzOVk73REMHiw+9ljvhjVIdMxiU/oXge9y7Ua7q6OlkJgmChaWrs06bHiwhJHz6yh+OXebVFbxHTsPdsw4w+Uv9/MB961zgR58yLVi6AJr5xosM8l92S/OJeG9paO43xuQGeX+mch7m/827VbeM8aLtRGXjNILC3BW+l9O++Yg0eF6YC4c6NobNOX4ZpfGNopDsoyYI19Yj9SoKvoqw3WtAZsX2T5CrAdG1PHLKNDwyCbuiYjlNKAAHy5ZCB7X63JrDAKgwUQSnYEPEGNVzisnNfyqVxQnvTDZLwgzWcYxTBCjXoO09+qsbB9lpgecT45UI80VgW70nokEzilmyXARG+eBGKhz2iJli+mrdZbpfzws/PD/Hr5dubgn8mNX5/e6DRMoTr9xQOGrvdXhET+ygiTEWg1VMzfcZ2WpeJTveV9h2BQ=
|
30
|
+
gem: fluent-plugin-input-gelf
|
31
|
+
on:
|
32
|
+
tags: true
|
33
|
+
repo: MerlinDMC/fluent-plugin-input-gelf
|
@@ -7,7 +7,7 @@ Gem::Specification.new do |gem|
|
|
7
7
|
gem.license = "MIT"
|
8
8
|
gem.homepage = "https://github.com/MerlinDMC/fluent-plugin-input-gelf"
|
9
9
|
gem.summary = gem.description
|
10
|
-
gem.version = "0.
|
10
|
+
gem.version = "0.3.1"
|
11
11
|
gem.authors = ["Daniel Malon"]
|
12
12
|
gem.email = "daniel.malon@me.com"
|
13
13
|
gem.has_rdoc = false
|
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
17
|
gem.require_paths = ['lib']
|
18
18
|
|
19
|
-
gem.add_runtime_dependency "fluentd"
|
19
|
+
gem.add_runtime_dependency "fluentd", [">= 0.14.10", "< 2"]
|
20
20
|
gem.add_runtime_dependency "gelfd2", ">= 0.3.0"
|
21
21
|
|
22
22
|
gem.add_development_dependency "bundler"
|
@@ -4,68 +4,52 @@ require 'time'
|
|
4
4
|
require 'cool.io'
|
5
5
|
require 'yajl'
|
6
6
|
|
7
|
-
require '
|
7
|
+
require 'gelfd2'
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
require 'fluent/plugin/input'
|
10
|
+
|
11
|
+
module Fluent::Plugin
|
12
|
+
class GelfInput < Fluent::Plugin::Input
|
11
13
|
Fluent::Plugin.register_input('gelf', self)
|
12
14
|
|
15
|
+
helpers :server, :parser, :compat_parameters
|
16
|
+
|
17
|
+
DEFAULT_PARSER = 'json'.freeze
|
18
|
+
|
13
19
|
def initialize
|
14
20
|
super
|
15
|
-
require 'fluent/plugin/socket_util'
|
16
|
-
require 'gelfd2'
|
17
21
|
end
|
18
22
|
|
19
23
|
desc "The value is the tag assigned to the generated events."
|
20
24
|
config_param :tag, :string
|
21
|
-
desc 'The format of the payload.'
|
22
|
-
config_param :format, :string, default: 'json'
|
23
25
|
desc 'The port to listen to.'
|
24
26
|
config_param :port, :integer, default: 12201
|
25
27
|
desc 'The bind address to listen to.'
|
26
28
|
config_param :bind, :string, default: '0.0.0.0'
|
27
29
|
desc 'The transport protocol used to receive logs.(udp, tcp)'
|
28
|
-
config_param :protocol_type,
|
29
|
-
case val.downcase
|
30
|
-
when 'tcp'
|
31
|
-
:tcp
|
32
|
-
when 'udp'
|
33
|
-
:udp
|
34
|
-
else
|
35
|
-
raise ConfigError, "gelf input protocol type should be 'tcp' or 'udp'"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
config_param :blocking_timeout, :time, default: 0.5
|
30
|
+
config_param :protocol_type, :enum, list: [:udp, :tcp], default: :udp
|
39
31
|
desc 'Strip leading underscore'
|
40
32
|
config_param :strip_leading_underscore, :bool, default: true
|
41
33
|
|
34
|
+
config_section :parse do
|
35
|
+
config_set_default :@type, DEFAULT_PARSER
|
36
|
+
end
|
37
|
+
|
42
38
|
def configure(conf)
|
39
|
+
compat_parameters_convert(conf, :parser)
|
43
40
|
super
|
44
41
|
|
45
|
-
@parser =
|
46
|
-
@parser.configure(conf)
|
42
|
+
@parser = parser_create
|
47
43
|
end
|
48
44
|
|
49
45
|
def start
|
50
|
-
|
51
|
-
@handler = listen(method(:receive_data))
|
52
|
-
@loop.attach(@handler)
|
46
|
+
super
|
53
47
|
|
54
|
-
|
48
|
+
listen
|
55
49
|
end
|
56
50
|
|
57
51
|
def shutdown
|
58
|
-
|
59
|
-
@loop.stop
|
60
|
-
@handler.close
|
61
|
-
@thread.join
|
62
|
-
end
|
63
|
-
|
64
|
-
def run
|
65
|
-
@loop.run(@blocking_timeout)
|
66
|
-
rescue
|
67
|
-
log.error 'unexpected error', error: $!.to_s
|
68
|
-
log.error_backtrace
|
52
|
+
super
|
69
53
|
end
|
70
54
|
|
71
55
|
def receive_data(data, addr)
|
@@ -86,7 +70,7 @@ module Fluent
|
|
86
70
|
end
|
87
71
|
|
88
72
|
# Use the recorded event time if available
|
89
|
-
time = record.delete('timestamp').
|
73
|
+
time = record.delete('timestamp').to_f if record.key?('timestamp')
|
90
74
|
|
91
75
|
# Postprocess recorded event
|
92
76
|
strip_leading_underscore_(record) if @strip_leading_underscore
|
@@ -98,14 +82,16 @@ module Fluent
|
|
98
82
|
log.error_backtrace
|
99
83
|
end
|
100
84
|
|
101
|
-
def listen
|
85
|
+
def listen
|
102
86
|
log.info "listening gelf socket on #{@bind}:#{@port} with #{@protocol_type}"
|
103
87
|
if @protocol_type == :tcp
|
104
|
-
|
88
|
+
server_create(:in_tcp_server, @port, bind: @bind) do |data, conn|
|
89
|
+
receive_data(data, conn)
|
90
|
+
end
|
105
91
|
else
|
106
|
-
@
|
107
|
-
|
108
|
-
|
92
|
+
server_create(:in_udp_server, @port, proto: :udp, bind: @bind, max_bytes: 8192) do |data, sock|
|
93
|
+
receive_data(data, sock)
|
94
|
+
end
|
109
95
|
end
|
110
96
|
end
|
111
97
|
|
data/test/plugin/test_in_gelf.rb
CHANGED
@@ -20,7 +20,7 @@ class GelfInputTest < Test::Unit::TestCase
|
|
20
20
|
!
|
21
21
|
|
22
22
|
def create_driver(conf)
|
23
|
-
Fluent::Test::
|
23
|
+
Fluent::Test::Driver::Input.new(Fluent::Plugin::GelfInput).configure(conf)
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_configure
|
@@ -31,7 +31,7 @@ class GelfInputTest < Test::Unit::TestCase
|
|
31
31
|
d = create_driver(v)
|
32
32
|
assert_equal PORT, d.instance.port
|
33
33
|
assert_equal k, d.instance.bind
|
34
|
-
assert_equal 'json', d.instance.
|
34
|
+
assert_equal 'json', d.instance.parser_configs.first["@type"]
|
35
35
|
}
|
36
36
|
end
|
37
37
|
|
@@ -48,22 +48,19 @@ class GelfInputTest < Test::Unit::TestCase
|
|
48
48
|
{:short_message => 'short message', :full_message => 'full message', :timestamp => 12345678.12345}
|
49
49
|
]
|
50
50
|
|
51
|
-
d.run do
|
51
|
+
d.run(expect_emits: 2) do
|
52
52
|
n = GELF::Notifier.new(k, PORT)
|
53
53
|
|
54
54
|
tests.each { |test|
|
55
55
|
n.notify!(test)
|
56
56
|
}
|
57
|
-
|
58
|
-
sleep 1
|
59
57
|
end
|
60
58
|
|
61
|
-
emits = d.
|
59
|
+
emits = d.events
|
62
60
|
assert_equal tests.length, emits.length, 'missing emitted events'
|
63
61
|
emits.each_index { |i|
|
64
|
-
puts emits[i].to_s
|
65
62
|
assert_equal 'gelf', emits[i][0]
|
66
|
-
assert_equal tests[i][:timestamp].
|
63
|
+
assert_equal tests[i][:timestamp].to_f, emits[i][1] unless tests[i][:timestamp].nil?
|
67
64
|
assert_equal tests[i][:short_message], emits[i][2]['short_message']
|
68
65
|
assert_equal tests[i][:full_message], emits[i][2]['full_message']
|
69
66
|
}
|
@@ -95,22 +92,19 @@ class GelfInputTest < Test::Unit::TestCase
|
|
95
92
|
}
|
96
93
|
]
|
97
94
|
|
98
|
-
d.run do
|
95
|
+
d.run(expect_emits: 1) do
|
99
96
|
n = GELF::Notifier.new(k, PORT)
|
100
97
|
|
101
98
|
tests.each { |test|
|
102
99
|
n.notify!(test[:given])
|
103
100
|
}
|
104
|
-
|
105
|
-
sleep 1
|
106
101
|
end
|
107
102
|
|
108
|
-
emits = d.
|
103
|
+
emits = d.events
|
109
104
|
assert_equal tests.length, emits.length, 'missing emitted events'
|
110
105
|
emits.each_index { |i|
|
111
|
-
puts emits[i].to_s
|
112
106
|
assert_equal 'gelf', emits[i][0]
|
113
|
-
assert_equal tests[i][:timestamp].
|
107
|
+
assert_equal tests[i][:timestamp].to_f, emits[i][1] unless tests[i][:timestamp].nil?
|
114
108
|
assert_block "expectation not met: #{tests[i][:expected]}" do
|
115
109
|
emits[i][2].merge(tests[i][:expected]) == emits[i][2]
|
116
110
|
end
|
data/test/test_helper.rb
CHANGED
@@ -13,16 +13,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
13
13
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
14
14
|
|
15
15
|
require 'fluent/test'
|
16
|
-
|
17
|
-
nulllogger = Object.new
|
18
|
-
nulllogger.instance_eval {|obj|
|
19
|
-
def method_missing(method, *args)
|
20
|
-
# pass
|
21
|
-
end
|
22
|
-
}
|
23
|
-
$log = nulllogger
|
24
|
-
end
|
25
|
-
|
16
|
+
require 'fluent/test/driver/input'
|
26
17
|
require 'fluent/plugin/in_gelf'
|
27
18
|
|
28
19
|
def unused_port
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-input-gelf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Malon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -16,14 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.14.10
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
29
|
+
version: 0.14.10
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: gelfd2
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,11 +135,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
135
|
- !ruby/object:Gem::Version
|
130
136
|
version: '0'
|
131
137
|
requirements: []
|
132
|
-
|
133
|
-
rubygems_version: 2.6.8
|
138
|
+
rubygems_version: 3.0.3
|
134
139
|
signing_key:
|
135
140
|
specification_version: 4
|
136
141
|
summary: A GELF input plugin for fluentd
|
137
|
-
test_files:
|
138
|
-
- test/plugin/test_in_gelf.rb
|
139
|
-
- test/test_helper.rb
|
142
|
+
test_files: []
|