fluent-plugin-input-gelf 0.1.1 → 0.3.2
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 +5 -5
- data/.travis.yml +23 -7
- data/fluent-plugin-input-gelf.gemspec +3 -3
- data/lib/fluent/plugin/in_gelf.rb +33 -44
- data/test/plugin/test_in_gelf.rb +8 -14
- data/test/test_helper.rb +1 -10
- metadata +14 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 02bd5fa91b5ed4ae973eb263a442407248fd8826e3dfd1ed1769f63084a6e1da
|
4
|
+
data.tar.gz: 5a09d5e7f2554da332b0dc9473783f03ece3cfbe2c06b146dab124d4f8c741ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10e6f1291630ff6132756346ec107a3aef63e4da756b2da6e6b0c4558a477d015aed0ddd908eb34a30eec3013956102892dd231b60d95d48317969b1186dc506
|
7
|
+
data.tar.gz: 7fe77c5b71561cbb0d5cbe70dffb1b81ffee52d832e04c0da9759d6eee518de386594eeece56c7702cf6258d7ed4f770aa0eaff2a8707e00406962e70b317757
|
data/.travis.yml
CHANGED
@@ -1,17 +1,33 @@
|
|
1
1
|
language: ruby
|
2
2
|
|
3
3
|
rvm:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
- 2.1
|
5
|
+
- 2.2
|
6
|
+
- 2.3
|
7
|
+
- 2.4
|
8
|
+
- 2.5
|
9
9
|
|
10
10
|
gemfile:
|
11
|
-
|
11
|
+
- Gemfile
|
12
12
|
|
13
13
|
branches:
|
14
14
|
only:
|
15
|
-
|
15
|
+
- master
|
16
|
+
# Tagged commits
|
17
|
+
- /^v\d+\.\d+(\.\d+)?(-\S*)?$/
|
16
18
|
|
17
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.2"
|
11
11
|
gem.authors = ["Daniel Malon"]
|
12
12
|
gem.email = "daniel.malon@me.com"
|
13
13
|
gem.has_rdoc = false
|
@@ -16,8 +16,8 @@ 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"
|
20
|
-
gem.add_runtime_dependency "
|
19
|
+
gem.add_runtime_dependency "fluentd", [">= 0.14.10", "< 2"]
|
20
|
+
gem.add_runtime_dependency "gelfd2", ">= 0.3.0"
|
21
21
|
|
22
22
|
gem.add_development_dependency "bundler"
|
23
23
|
gem.add_development_dependency "rake"
|
@@ -4,73 +4,57 @@ 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 'gelfd'
|
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)
|
72
56
|
begin
|
73
|
-
msg =
|
57
|
+
msg = Gelfd2::Parser.parse(data)
|
74
58
|
rescue => e
|
75
59
|
log.warn 'Gelfd failed to parse a message', error: e.to_s
|
76
60
|
log.warn_backtrace
|
@@ -86,10 +70,10 @@ 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
|
93
77
|
|
94
78
|
emit(time, record)
|
95
79
|
}
|
@@ -98,14 +82,19 @@ 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
|
+
# Graylog is ready to accept 8192 bytes of GELF, but with
|
93
|
+
# chunking we need to accept at least 12 bytes of chunk header
|
94
|
+
# as well. But we don't need to pin us down to that either.
|
95
|
+
server_create(:in_udp_server, @port, proto: :udp, bind: @bind, max_bytes: 65536) do |data, sock|
|
96
|
+
receive_data(data, sock)
|
97
|
+
end
|
109
98
|
end
|
110
99
|
end
|
111
100
|
|
@@ -117,7 +106,7 @@ module Fluent
|
|
117
106
|
|
118
107
|
private
|
119
108
|
|
120
|
-
def
|
109
|
+
def strip_leading_underscore_(record)
|
121
110
|
record.keys.each { |k|
|
122
111
|
next unless k[0,1] == '_'
|
123
112
|
record[k[1..-1]] = record.delete(k)
|
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.2
|
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: 2022-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -16,28 +16,34 @@ 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
|
-
name:
|
34
|
+
name: gelfd2
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
37
|
- - ">="
|
32
38
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
39
|
+
version: 0.3.0
|
34
40
|
type: :runtime
|
35
41
|
prerelease: false
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
37
43
|
requirements:
|
38
44
|
- - ">="
|
39
45
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
46
|
+
version: 0.3.0
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: bundler
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,8 +135,7 @@ 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.5.1
|
138
|
+
rubygems_version: 3.0.3.1
|
134
139
|
signing_key:
|
135
140
|
specification_version: 4
|
136
141
|
summary: A GELF input plugin for fluentd
|