fluent-plugin-beats 0.1.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +10 -1
- data/VERSION +1 -1
- data/lib/fluent/plugin/in_beats.rb +32 -20
- data/test/plugin/test_in_beats.rb +39 -7
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 73b84f27924633682deed6e9a10728e152b48a7d
|
4
|
+
data.tar.gz: 9d943e19a7a44fff61ff4e30bb1af64340552e67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c81ee764955868ff64a2565c3c0a41e07fdda4a607c820383d615667121edbcbc10274bb864b41775cea7ccac5b1ed703e04b5e704d4708900e8837496788000
|
7
|
+
data.tar.gz: 3dd3d1d206f46bfd93fb4fb9bf81d8a6eab6a4f0f98b25c5ab76220d0a5f346ac04fc45edf0d18a6738d3d498ee6770fbe281515a19c7caa1f42a8546f45a37e
|
data/README.md
CHANGED
@@ -4,9 +4,16 @@
|
|
4
4
|
|
5
5
|
This plugin uses lumberjack protocol for communicating with each beat.
|
6
6
|
|
7
|
+
## Requirements
|
8
|
+
|
9
|
+
| fluent-plugin-beats | fluentd | ruby |
|
10
|
+
|-------------------|---------|------|
|
11
|
+
| >= 1.0.0 | >= v1.0.0 | >= 2.1 |
|
12
|
+
| < 1.0.0 | >= v0.12.0 | >= 1.9 |
|
13
|
+
|
7
14
|
## Installation
|
8
15
|
|
9
|
-
$ gem install fluent-plugin-beats
|
16
|
+
$ gem install fluent-plugin-beats --no-document
|
10
17
|
|
11
18
|
## Configuration
|
12
19
|
|
@@ -29,6 +36,8 @@ Configuration example:
|
|
29
36
|
|
30
37
|
The port to listen to. Default Value is `5044`.
|
31
38
|
|
39
|
+
If you use this plugin under multi-process environment in v1, the plugin will be launched in each worker. Port is assigned in sequential number, e.g. 5044, 5045 ... 504N.
|
40
|
+
|
32
41
|
**bind**
|
33
42
|
|
34
43
|
The bind address to listen to. Default Value is 0.0.0.0 (all addresses)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
1.0.0
|
@@ -15,44 +15,57 @@
|
|
15
15
|
# See the License for the specific language governing permissions and
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
|
+
require "lumberjack/beats"
|
19
|
+
require "lumberjack/beats/server"
|
20
|
+
require 'concurrent/executor/cached_thread_pool'
|
18
21
|
|
19
|
-
require 'fluent/input'
|
20
|
-
require 'fluent/parser'
|
22
|
+
require 'fluent/plugin/input'
|
23
|
+
require 'fluent/plugin/parser'
|
24
|
+
require 'fluent/time'
|
21
25
|
|
22
|
-
module Fluent
|
26
|
+
module Fluent::Plugin
|
23
27
|
class BeatsInput < Input
|
24
|
-
Plugin.register_input('beats', self)
|
28
|
+
Fluent::Plugin.register_input('beats', self)
|
25
29
|
|
26
|
-
|
27
|
-
super
|
30
|
+
include Fluent::TimeMixin::Parser
|
28
31
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
32
|
+
helpers :compat_parameters, :parser, :thread
|
33
|
+
|
34
|
+
DEFAULT_PARSER = 'none'.freeze
|
33
35
|
|
34
36
|
config_param :port, :integer, :default => 5044
|
35
37
|
config_param :bind, :string, :default => '0.0.0.0'
|
36
38
|
config_param :tag, :string, :default => nil
|
37
39
|
config_param :metadata_as_tag, :bool, :default => nil
|
38
|
-
config_param :format, :string, :default => nil
|
39
40
|
config_param :max_connections, :integer, :default => nil # CachedThreadPool can't limit the number of threads
|
40
41
|
config_param :use_ssl, :string, :default => false
|
41
42
|
config_param :ssl_certificate, :string, :default => nil
|
42
43
|
config_param :ssl_key, :string, :default => nil
|
43
44
|
config_param :ssl_key_passphrase, :string, :default => nil
|
44
45
|
|
46
|
+
config_section :parse do
|
47
|
+
config_set_default :@type, DEFAULT_PARSER
|
48
|
+
end
|
49
|
+
|
50
|
+
def multi_workers_ready?
|
51
|
+
true
|
52
|
+
end
|
53
|
+
|
45
54
|
def configure(conf)
|
55
|
+
compat_parameters_convert(conf, :parser)
|
56
|
+
|
46
57
|
super
|
47
58
|
|
48
59
|
if !@tag && !@metadata_as_tag
|
49
|
-
raise ConfigError, "'tag' or 'metadata_as_tag' parameter is required on beats input"
|
60
|
+
raise Fluent::ConfigError, "'tag' or 'metadata_as_tag' parameter is required on beats input"
|
50
61
|
end
|
51
62
|
|
52
|
-
@
|
53
|
-
|
54
|
-
|
55
|
-
|
63
|
+
@port += fluentd_worker_id
|
64
|
+
@time_parser = time_parser_create(format: '%Y-%m-%dT%H:%M:%S.%N%z')
|
65
|
+
|
66
|
+
@parser_config = conf.elements('parse').first
|
67
|
+
if @parser_config
|
68
|
+
@parser = parser_create
|
56
69
|
end
|
57
70
|
@connections = []
|
58
71
|
end
|
@@ -66,13 +79,12 @@ module Fluent
|
|
66
79
|
# Lumberjack::Beats::Server depends on normal accept so we need to launch thread for each connection.
|
67
80
|
# TODO: Re-implement Beats Server with Cool.io for resource control
|
68
81
|
@thread_pool = Concurrent::CachedThreadPool.new(:idletime => 15) # idletime setting is based on logstash beats input
|
69
|
-
|
82
|
+
thread_create(:in_beats_runner, &method(:run))
|
70
83
|
end
|
71
84
|
|
72
85
|
def shutdown
|
73
86
|
@lumberjack.close rescue nil
|
74
87
|
@thread_pool.shutdown
|
75
|
-
@thread.join
|
76
88
|
|
77
89
|
super
|
78
90
|
end
|
@@ -88,7 +100,7 @@ module Fluent
|
|
88
100
|
conn.close # close for retry on beats side
|
89
101
|
sleep 1
|
90
102
|
next
|
91
|
-
end
|
103
|
+
end
|
92
104
|
@connections << conn
|
93
105
|
end
|
94
106
|
|
@@ -97,7 +109,7 @@ module Fluent
|
|
97
109
|
conn.run { |map|
|
98
110
|
tag = @metadata_as_tag ? map['@metadata']['beat'] : @tag
|
99
111
|
|
100
|
-
if map.has_key?('message') && @
|
112
|
+
if map.has_key?('message') && @parser_config
|
101
113
|
message = map.delete('message')
|
102
114
|
@parser.parse(message) { |time, record|
|
103
115
|
record['@timestamp'] = map['@timestamp']
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'fluent/test'
|
2
|
+
require 'fluent/test/driver/input'
|
2
3
|
require 'fluent/plugin/in_beats'
|
3
4
|
require 'lumberjack/beats/client'
|
4
5
|
require 'helper'
|
@@ -18,7 +19,7 @@ class BeatsInputTest < Test::Unit::TestCase
|
|
18
19
|
]
|
19
20
|
|
20
21
|
def create_driver(conf=CONFIG)
|
21
|
-
Fluent::Test::
|
22
|
+
Fluent::Test::Driver::Input.new(Fluent::Plugin::BeatsInput).configure(conf)
|
22
23
|
end
|
23
24
|
|
24
25
|
def create_client
|
@@ -52,11 +53,11 @@ class BeatsInputTest < Test::Unit::TestCase
|
|
52
53
|
client.write(payload)
|
53
54
|
end
|
54
55
|
|
55
|
-
|
56
|
-
assert_equal
|
56
|
+
es = d.events
|
57
|
+
assert_equal es[0][0], 'test.beats'
|
57
58
|
assert_equal es.length, 1
|
58
59
|
|
59
|
-
time, record = es[0]
|
60
|
+
tag, time, record = es[0]
|
60
61
|
assert_equal time.to_i, Time.parse(timestamp).to_i
|
61
62
|
assert_equal record, payload
|
62
63
|
end
|
@@ -76,12 +77,43 @@ class BeatsInputTest < Test::Unit::TestCase
|
|
76
77
|
client.write(payload)
|
77
78
|
end
|
78
79
|
|
79
|
-
|
80
|
-
assert_equal
|
80
|
+
es = d.events
|
81
|
+
assert_equal es[0][0], 'heartbeat'
|
81
82
|
assert_equal es.length, 1
|
82
83
|
|
83
|
-
time, record = es[0]
|
84
|
+
tag, time, record = es[0]
|
84
85
|
assert_equal time.to_i, Time.parse(timestamp).to_i
|
85
86
|
assert_equal record, payload
|
86
87
|
end
|
88
|
+
|
89
|
+
def test_input_as_json
|
90
|
+
d = create_driver(CONFIG + %[format json])
|
91
|
+
|
92
|
+
timestamp = '2018-01-01T12:30:00.000Z'
|
93
|
+
payload = {
|
94
|
+
'@metadata' => {'beat' => 'heartbeat'},
|
95
|
+
'@timestamp' => timestamp,
|
96
|
+
'message' => '{"msg":"as_json"}'
|
97
|
+
}
|
98
|
+
expected = {
|
99
|
+
'@metadata' => {'beat' => 'heartbeat'},
|
100
|
+
'@timestamp' => timestamp,
|
101
|
+
'msg' => 'as_json'
|
102
|
+
}
|
103
|
+
|
104
|
+
now = Fluent::Engine.now
|
105
|
+
d.run do
|
106
|
+
client = create_client
|
107
|
+
client.write(payload)
|
108
|
+
end
|
109
|
+
|
110
|
+
es = d.events
|
111
|
+
assert_equal es[0][0], 'test.beats'
|
112
|
+
assert_equal es.length, 1
|
113
|
+
|
114
|
+
_tag, time, record = es[0]
|
115
|
+
assert_in_delta now, time, 1.0
|
116
|
+
assert_equal record["@timestamp"], timestamp
|
117
|
+
assert_equal record, expected
|
118
|
+
end
|
87
119
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-beats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masahiro Nakagawa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -132,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
132
|
version: '0'
|
133
133
|
requirements: []
|
134
134
|
rubyforge_project:
|
135
|
-
rubygems_version: 2.
|
135
|
+
rubygems_version: 2.6.14.1
|
136
136
|
signing_key:
|
137
137
|
specification_version: 4
|
138
138
|
summary: Elastic beats plugin for Fluentd event collector
|