fluent-plugin-remote_syslog 0.3.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/test.yaml +26 -0
- data/CHANGELOG.md +12 -0
- data/README.md +71 -6
- data/VERSION +1 -1
- data/fluent-plugin-remote_syslog.gemspec +7 -9
- data/lib/fluent/plugin/out_remote_syslog.rb +156 -38
- data/test/plugin/out_remote_syslog.rb +109 -31
- data/test/test_helper.rb +6 -3
- metadata +21 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 34d4b7218edc54b5340ea9d168603f72d50ed038cc6b262b22a5a2045c00aa50
|
4
|
+
data.tar.gz: 3f2340c1507f45567d45e6b57c2129978ee2e01809567a68dc8438ce6fc1eec0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6fca5b050b67064465bdf08bdb53e650d5aa73f53b9d8cfc847717fdda4c2bf18f6ba9ad67a835430b8a1e88eedbcf138f77c85132d11813f109dd7aa5412e0
|
7
|
+
data.tar.gz: fbaf7442c5e3bc25618678250bad84d2099dc7216c21938f5c5d083b4788f9e9446fdaa2a027ddd76376d0d1d93509f4bdd6983b43fe0176122b443c6b91d4d6
|
@@ -0,0 +1,26 @@
|
|
1
|
+
on:
|
2
|
+
- push
|
3
|
+
- pull_request
|
4
|
+
name: Unit test
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
runs-on: ${{ matrix.os }}
|
8
|
+
strategy:
|
9
|
+
fail-fast: false
|
10
|
+
matrix:
|
11
|
+
ruby: [ '2.7', '3.1' ]
|
12
|
+
os:
|
13
|
+
- windows-latest
|
14
|
+
- ubuntu-latest
|
15
|
+
- macos-latest
|
16
|
+
name: Test on ${{ matrix.os }} with Ruby ${{ matrix.ruby }}
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v2
|
19
|
+
- name: Set up Ruby
|
20
|
+
uses: ruby/setup-ruby@v1
|
21
|
+
with:
|
22
|
+
ruby-version: ${{ matrix.ruby }}
|
23
|
+
- name: Install dependencies
|
24
|
+
run: bundle
|
25
|
+
- name: Run tests
|
26
|
+
run: bundle exec rake test
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
## 1.1.0
|
2
|
+
|
3
|
+
* Up rake dependency version for CVE-2020-8130
|
4
|
+
* Support "warning" Severity in addition to "warn" [#51](https://github.com/fluent-plugins-nursery/fluent-plugin-remote_syslog/pull/51)
|
5
|
+
* Make `packet_size` option valid to UDP [#46](https://github.com/fluent-plugins-nursery/fluent-plugin-remote_syslog/pull/46)
|
6
|
+
|
7
|
+
## 1.0.0
|
8
|
+
|
9
|
+
* Support fluentd-0.14 or later features [#24](https://github.com/dlackty/fluent-plugin-remote_syslog/pull/24)
|
10
|
+
* Support TCP and TLS protocol [#24](https://github.com/dlackty/fluent-plugin-remote_syslog/pull/24)
|
11
|
+
* Not support fluentd-0.12.0 from this version
|
12
|
+
|
1
13
|
## 0.3.3
|
2
14
|
|
3
15
|
* Allow override "severity" or "facility" from records [#19](https://github.com/dlackty/fluent-plugin-remote_syslog/pull/19)
|
data/README.md
CHANGED
@@ -4,26 +4,91 @@
|
|
4
4
|
|
5
5
|
[Fluentd](http://fluentd.org) plugin for output to remote syslog serivce (e.g. [Papertrail](http://papertrailapp.com/))
|
6
6
|
|
7
|
+
## Requirements
|
8
|
+
|
9
|
+
| fluent-plugin-remote_syslog | fluentd | ruby |
|
10
|
+
| ------------------- | --------- | ------ |
|
11
|
+
| >= 1.0.0 | >= v0.14.0 or >= v1.0.0 | >= 2.1 |
|
12
|
+
| < 1.0.0 | >= v0.12.0 | >= 1.9 |
|
13
|
+
|
7
14
|
## Installation
|
8
15
|
|
16
|
+
* Fluentd
|
17
|
+
|
18
|
+
```bash
|
19
|
+
$ fluent-gem install fluent-plugin-remote_syslog
|
20
|
+
```
|
21
|
+
|
22
|
+
* td-agent
|
23
|
+
|
9
24
|
```bash
|
10
|
-
|
25
|
+
$ td-agent-gem install fluent-plugin-remote_syslog
|
11
26
|
```
|
12
27
|
|
13
28
|
## Usage
|
14
29
|
|
15
30
|
```
|
16
|
-
<match foo>
|
17
|
-
type remote_syslog
|
31
|
+
<match foo.bar>
|
32
|
+
@type remote_syslog
|
18
33
|
host example.com
|
19
34
|
port 514
|
20
35
|
severity debug
|
21
|
-
|
36
|
+
program fluentd
|
37
|
+
hostname ${tag[1]}
|
38
|
+
|
39
|
+
<buffer tag>
|
40
|
+
</buffer>
|
41
|
+
|
42
|
+
<format>
|
43
|
+
@type single_value
|
44
|
+
message_key message
|
45
|
+
</format>
|
22
46
|
</match>
|
23
47
|
```
|
24
48
|
|
25
|
-
|
49
|
+
## Configuration
|
50
|
+
|
51
|
+
| name | type | placeholder support | description |
|
52
|
+
| -------------- | ------- | ----------- | --------------------------------- |
|
53
|
+
| hostname | string | support | departure of log |
|
54
|
+
| host | string | support | syslog target host |
|
55
|
+
| port | integer (default: `514`) | | syslog target port |
|
56
|
+
| host_with_port | string | support | parameter for <host>:<port> style |
|
57
|
+
| facility | string (default: `"user"`) | support | syslog facility |
|
58
|
+
| severity | string (default: `"notice"` | support | syslog severity |
|
59
|
+
| program | string (default: `"fluentd"` | support | syslog program name |
|
60
|
+
| protocol | enum (udp, tcp) (default: `udp`) | | transfer protocol |
|
61
|
+
| tls | bool (default: false) | | use TLS (tcp only) |
|
62
|
+
| ca_file | string | | ca_file path (tls mode only) |
|
63
|
+
| verify_mode | integer | | SSL verification mode (tls mode only) |
|
64
|
+
| packet_size | integer (default: `1024`) | | size limitation for syslog packet |
|
65
|
+
| timeout | integer | | TCP transfer timeout. if value is 0, wait forever |
|
66
|
+
| timeout_exception | bool (default: `false`) | | if value is true, raise exception by transfer timeout |
|
67
|
+
| keep_alive | bool (default: `false`) | | use TCP keep alive |
|
68
|
+
| keep_alive_idle | integer | | set TCP keep alive idle time |
|
69
|
+
| keep_alive_cnt | integer | | set TCP keep alive probe count |
|
70
|
+
| keep_alive_intvl | integer | | set TCP keep alive probe interval |
|
71
|
+
|
72
|
+
### Common Configuration
|
73
|
+
|
74
|
+
#### Buffer Section
|
75
|
+
|
76
|
+
| name | default |
|
77
|
+
| -------------- | ------- |
|
78
|
+
| flush_mode | interval |
|
79
|
+
| flush_interval | 5 |
|
80
|
+
| flush_thread_interval | 0.5 |
|
81
|
+
| flush_thread_burst_interval | 0.5 |
|
82
|
+
|
83
|
+
#### Format Section
|
84
|
+
|
85
|
+
| name | default |
|
86
|
+
| -------------- | ------- |
|
87
|
+
| @type | ltsv |
|
26
88
|
|
27
89
|
## License
|
28
90
|
|
29
|
-
Copyright (c) 2014-2017 Richard Lee.
|
91
|
+
Copyright (c) 2014-2017 Richard Lee.
|
92
|
+
Copyright (c) 2022 Daijiro Fukuda.
|
93
|
+
|
94
|
+
See LICENSE for details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
1.1.0
|
@@ -5,8 +5,8 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "fluent-plugin-remote_syslog"
|
7
7
|
spec.version = File.read("VERSION").strip
|
8
|
-
spec.authors = ["Richard Lee"]
|
9
|
-
spec.email = ["dlackty@gmail.com"]
|
8
|
+
spec.authors = ["Richard Lee", "Daijiro Fukuda"]
|
9
|
+
spec.email = ["dlackty@gmail.com", "fukuda@clear-code.com"]
|
10
10
|
spec.summary = %q{Fluentd output plugin for remote syslog}
|
11
11
|
spec.description = spec.description
|
12
12
|
spec.homepage = "https://github.com/dlackty/fluent-plugin-remote_syslog"
|
@@ -16,13 +16,11 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
17
|
spec.require_paths = ["lib"]
|
18
18
|
|
19
|
-
spec.add_development_dependency "
|
20
|
-
spec.add_development_dependency "
|
21
|
-
spec.add_development_dependency "
|
19
|
+
spec.add_development_dependency "bundler", '~> 2.0'
|
20
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
21
|
+
spec.add_development_dependency "test-unit"
|
22
|
+
spec.add_development_dependency "test-unit-rr"
|
22
23
|
|
23
24
|
spec.add_runtime_dependency "fluentd"
|
24
|
-
spec.add_runtime_dependency "
|
25
|
-
spec.add_runtime_dependency "remote_syslog_logger", "~> 1.0.0"
|
26
|
-
spec.add_runtime_dependency "fluent-mixin-config-placeholders"
|
27
|
-
spec.add_runtime_dependency "fluent-mixin-rewrite-tag-name"
|
25
|
+
spec.add_runtime_dependency "remote_syslog_sender", ">= 1.1.1"
|
28
26
|
end
|
@@ -1,54 +1,172 @@
|
|
1
|
-
require "
|
2
|
-
require "fluent/mixin/plaintextformatter"
|
3
|
-
require 'fluent/mixin/rewrite_tag_name'
|
1
|
+
require "remote_syslog_sender"
|
4
2
|
|
5
3
|
module Fluent
|
6
|
-
|
7
|
-
|
4
|
+
module Plugin
|
5
|
+
class RemoteSyslogOutput < Output
|
6
|
+
Fluent::Plugin.register_output("remote_syslog", self)
|
8
7
|
|
9
|
-
|
8
|
+
helpers :formatter, :inject
|
10
9
|
|
11
|
-
|
12
|
-
include Fluent::Mixin::ConfigPlaceholders
|
13
|
-
include Fluent::HandleTagNameMixin
|
14
|
-
include Fluent::Mixin::RewriteTagName
|
10
|
+
config_param :hostname, :string, :default => ""
|
15
11
|
|
16
|
-
|
17
|
-
|
12
|
+
config_param :host, :string, :default => nil
|
13
|
+
config_param :port, :integer, :default => 514
|
14
|
+
config_param :host_with_port, :string, :default => nil
|
18
15
|
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
config_param :facility, :string, :default => "user"
|
17
|
+
config_param :severity, :string, :default => "notice"
|
18
|
+
config_param :program, :string, :default => "fluentd"
|
22
19
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
20
|
+
config_param :protocol, :enum, list: [:udp, :tcp], :default => :udp
|
21
|
+
config_param :tls, :bool, :default => false
|
22
|
+
config_param :ca_file, :string, :default => nil
|
23
|
+
config_param :verify_mode, :integer, default: nil
|
24
|
+
config_param :packet_size, :size, default: 1024
|
25
|
+
config_param :timeout, :time, default: nil
|
26
|
+
config_param :timeout_exception, :bool, default: false
|
28
27
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
config_param :keep_alive, :bool, :default => false
|
29
|
+
config_param :keep_alive_idle, :integer, :default => nil
|
30
|
+
config_param :keep_alive_cnt, :integer, :default => nil
|
31
|
+
config_param :keep_alive_intvl, :integer, :default => nil
|
32
|
+
|
33
|
+
config_section :buffer do
|
34
|
+
config_set_default :flush_mode, :interval
|
35
|
+
config_set_default :flush_interval, 5
|
36
|
+
config_set_default :flush_thread_interval, 0.5
|
37
|
+
config_set_default :flush_thread_burst_interval, 0.5
|
38
|
+
end
|
39
|
+
|
40
|
+
config_section :format do
|
41
|
+
config_set_default :@type, 'ltsv'
|
42
|
+
end
|
43
|
+
|
44
|
+
def initialize
|
45
|
+
super
|
46
|
+
end
|
47
|
+
|
48
|
+
def configure(conf)
|
49
|
+
super
|
50
|
+
if @host.nil? && @host_with_port.nil?
|
51
|
+
raise ConfigError, "host or host_with_port is required"
|
52
|
+
end
|
53
|
+
|
54
|
+
@formatter = formatter_create
|
55
|
+
unless @formatter.formatter_type == :text_per_line
|
56
|
+
raise ConfigError, "formatter_type must be text_per_line formatter"
|
57
|
+
end
|
58
|
+
|
59
|
+
validate_target = "host=#{@host}/host_with_port=#{@host_with_port}/hostname=#{@hostname}/facility=#{@facility}/severity=#{@severity}/program=#{@program}"
|
60
|
+
placeholder_validate!(:remote_syslog, validate_target)
|
61
|
+
@senders = []
|
62
|
+
end
|
63
|
+
|
64
|
+
def multi_workers_ready?
|
65
|
+
true
|
66
|
+
end
|
67
|
+
|
68
|
+
def close
|
69
|
+
super
|
70
|
+
@senders.each { |s| s.close if s }
|
71
|
+
@senders.clear
|
72
|
+
end
|
33
73
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
74
|
+
def format(tag, time, record)
|
75
|
+
r = inject_values_to_record(tag, time, record)
|
76
|
+
@formatter.format(tag, time, r)
|
77
|
+
end
|
78
|
+
|
79
|
+
def write(chunk)
|
80
|
+
return if chunk.empty?
|
81
|
+
|
82
|
+
host = extract_placeholders(@host, chunk.metadata)
|
83
|
+
port = @port
|
84
|
+
|
85
|
+
if @host_with_port
|
86
|
+
host, port = extract_placeholders(@host_with_port, chunk.metadata).split(":")
|
87
|
+
end
|
88
|
+
|
89
|
+
host_with_port = "#{host}:#{port}"
|
90
|
+
|
91
|
+
Thread.current[host_with_port] ||= create_sender(host, port)
|
92
|
+
sender = Thread.current[host_with_port]
|
93
|
+
|
94
|
+
facility = extract_placeholders(@facility, chunk.metadata)
|
95
|
+
severity = extract_placeholders(@severity, chunk.metadata)
|
96
|
+
program = extract_placeholders(@program, chunk.metadata)
|
97
|
+
hostname = extract_placeholders(@hostname, chunk.metadata)
|
98
|
+
|
99
|
+
severity = SeverityMapper.map(severity)
|
100
|
+
|
101
|
+
packet_options = {facility: facility, severity: severity, program: program}
|
102
|
+
packet_options[:hostname] = hostname unless hostname.empty?
|
103
|
+
|
104
|
+
begin
|
105
|
+
chunk.open do |io|
|
106
|
+
io.each_line do |msg|
|
107
|
+
sender.transmit(msg.chomp!, packet_options)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
rescue
|
111
|
+
if Thread.current[host_with_port]
|
112
|
+
Thread.current[host_with_port].close
|
113
|
+
@senders.delete(Thread.current[host_with_port])
|
114
|
+
Thread.current[host_with_port] = nil
|
40
115
|
end
|
116
|
+
raise
|
41
117
|
end
|
118
|
+
end
|
42
119
|
|
43
|
-
|
44
|
-
@loggers[tag] ||= RemoteSyslogLogger::UdpSender.new(@host,
|
45
|
-
@port,
|
46
|
-
facility: record["facility"] || @facility,
|
47
|
-
severity: record["severity"] || @severity,
|
48
|
-
program: tag,
|
49
|
-
local_hostname: @hostname)
|
120
|
+
private
|
50
121
|
|
51
|
-
|
122
|
+
def create_sender(host, port)
|
123
|
+
if @protocol == :tcp
|
124
|
+
options = {
|
125
|
+
tls: @tls,
|
126
|
+
whinyerrors: true,
|
127
|
+
packet_size: @packet_size,
|
128
|
+
timeout: @timeout,
|
129
|
+
timeout_exception: @timeout_exception,
|
130
|
+
keep_alive: @keep_alive,
|
131
|
+
keep_alive_idle: @keep_alive_idle,
|
132
|
+
keep_alive_cnt: @keep_alive_cnt,
|
133
|
+
keep_alive_intvl: @keep_alive_intvl,
|
134
|
+
program: @program,
|
135
|
+
}
|
136
|
+
options[:ca_file] = @ca_file if @ca_file
|
137
|
+
options[:verify_mode] = @verify_mode if @verify_mode
|
138
|
+
sender = RemoteSyslogSender::TcpSender.new(
|
139
|
+
host,
|
140
|
+
port,
|
141
|
+
options
|
142
|
+
)
|
143
|
+
else
|
144
|
+
sender = RemoteSyslogSender::UdpSender.new(
|
145
|
+
host,
|
146
|
+
port,
|
147
|
+
whinyerrors: true,
|
148
|
+
program: @program,
|
149
|
+
packet_size: @packet_size,
|
150
|
+
)
|
151
|
+
end
|
152
|
+
@senders << sender
|
153
|
+
sender
|
154
|
+
end
|
155
|
+
|
156
|
+
# Convert some Severity values that is not supported in `syslog_protocol` library:
|
157
|
+
# https://github.com/eric/syslog_protocol
|
158
|
+
# We want to fix `syslog_protocol` itself, but it seems to be not maintained for a while.
|
159
|
+
# If the following PR is merged, we can remove this implementaion.
|
160
|
+
# https://github.com/eric/syslog_protocol/pull/9
|
161
|
+
module SeverityMapper
|
162
|
+
DICT = {
|
163
|
+
# "warning" is not supported, but we should use it since "warn" is deprecated.
|
164
|
+
"warning" => "warn",
|
165
|
+
}
|
166
|
+
|
167
|
+
def self.map(severity)
|
168
|
+
DICT[severity] || severity
|
169
|
+
end
|
52
170
|
end
|
53
171
|
end
|
54
172
|
end
|
@@ -1,62 +1,140 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
require "fluent/plugin/out_remote_syslog"
|
3
|
+
require "fluent/plugin/in_syslog"
|
4
|
+
require 'fluent/test/driver/input'
|
3
5
|
|
4
|
-
class RemoteSyslogOutputTest <
|
6
|
+
class RemoteSyslogOutputTest < Test::Unit::TestCase
|
5
7
|
def setup
|
6
8
|
Fluent::Test.setup
|
7
9
|
end
|
8
10
|
|
9
|
-
def
|
10
|
-
Fluent::Test::
|
11
|
+
def create_driver_out_syslog(conf)
|
12
|
+
Fluent::Test::Driver::Output.new(Fluent::Plugin::RemoteSyslogOutput).configure(conf)
|
13
|
+
end
|
14
|
+
|
15
|
+
def create_driver_in_syslog(conf)
|
16
|
+
Fluent::Test::Driver::Input.new(Fluent::Plugin::SyslogInput).configure(conf)
|
11
17
|
end
|
12
18
|
|
13
19
|
def test_configure
|
14
|
-
d =
|
15
|
-
type remote_syslog
|
20
|
+
d = create_driver_out_syslog %[
|
21
|
+
@type remote_syslog
|
16
22
|
hostname foo.com
|
17
23
|
host example.com
|
18
24
|
port 5566
|
19
25
|
severity debug
|
20
|
-
|
26
|
+
program minitest
|
21
27
|
]
|
22
28
|
|
23
|
-
d.
|
24
|
-
|
25
|
-
|
29
|
+
loggers = d.instance.instance_variable_get(:@senders)
|
30
|
+
assert_equal loggers, []
|
31
|
+
|
32
|
+
assert_equal "example.com", d.instance.instance_variable_get(:@host)
|
33
|
+
assert_equal 5566, d.instance.instance_variable_get(:@port)
|
34
|
+
assert_equal "debug", d.instance.instance_variable_get(:@severity)
|
35
|
+
end
|
36
|
+
|
37
|
+
data("debug", {severity: "debug"})
|
38
|
+
data("warn", {severity: "warn"})
|
39
|
+
data("warning", {severity: "warning", expected_severity: "warn"})
|
40
|
+
def test_write_udp(data)
|
41
|
+
out_driver = create_driver_out_syslog %[
|
42
|
+
@type remote_syslog
|
43
|
+
hostname foo.com
|
44
|
+
host localhost
|
45
|
+
port 5566
|
46
|
+
severity #{data[:severity]}
|
47
|
+
program minitest
|
48
|
+
|
49
|
+
<format>
|
50
|
+
@type single_value
|
51
|
+
message_key message
|
52
|
+
</format>
|
53
|
+
]
|
54
|
+
|
55
|
+
in_driver = create_driver_in_syslog %[
|
56
|
+
@type syslog
|
57
|
+
tag tag
|
58
|
+
port 5566
|
59
|
+
bind 127.0.0.1
|
60
|
+
]
|
26
61
|
|
27
|
-
|
28
|
-
|
62
|
+
in_driver.run(expect_records: 1, timeout: 5) do
|
63
|
+
out_driver.run do
|
64
|
+
out_driver.feed("tag", Fluent::EventTime.now, {"message" => "This is a test message."})
|
65
|
+
end
|
66
|
+
end
|
29
67
|
|
30
|
-
|
68
|
+
assert_equal 1, in_driver.events.length
|
31
69
|
|
32
|
-
|
33
|
-
assert_equal 5566, logger.instance_variable_get(:@remote_port)
|
70
|
+
tag, _, msg = in_driver.events[0]
|
34
71
|
|
35
|
-
|
36
|
-
|
37
|
-
assert_equal
|
38
|
-
assert_equal
|
39
|
-
assert_equal
|
72
|
+
expected_facility = "user"
|
73
|
+
expected_severity = data[:expected_severity] || data[:severity]
|
74
|
+
assert_equal("tag.#{expected_facility}.#{expected_severity}", tag)
|
75
|
+
assert_equal("foo.com", msg["host"])
|
76
|
+
assert_equal("minitest", msg["ident"])
|
77
|
+
assert_equal("This is a test message.", msg["message"])
|
40
78
|
end
|
41
79
|
|
42
|
-
|
43
|
-
|
44
|
-
|
80
|
+
data("debug", {severity: "debug"})
|
81
|
+
data("warn", {severity: "warn"})
|
82
|
+
data("warning", {severity: "warning", expected_severity: "warn"})
|
83
|
+
def test_write_tcp(data)
|
84
|
+
out_driver = create_driver_out_syslog %[
|
85
|
+
@type remote_syslog
|
45
86
|
hostname foo.com
|
46
|
-
host
|
87
|
+
host localhost
|
47
88
|
port 5566
|
48
|
-
severity
|
49
|
-
|
89
|
+
severity #{data[:severity]}
|
90
|
+
program minitest
|
91
|
+
|
92
|
+
protocol tcp
|
93
|
+
|
94
|
+
<format>
|
95
|
+
@type single_value
|
96
|
+
message_key message
|
97
|
+
</format>
|
50
98
|
]
|
51
99
|
|
52
|
-
|
53
|
-
|
100
|
+
in_driver = create_driver_in_syslog %[
|
101
|
+
@type syslog
|
102
|
+
tag tag
|
103
|
+
port 5566
|
104
|
+
bind 127.0.0.1
|
105
|
+
protocol_type tcp
|
106
|
+
]
|
107
|
+
|
108
|
+
in_driver.run(expect_records: 1, timeout: 5) do
|
109
|
+
out_driver.run do
|
110
|
+
out_driver.feed("tag", Fluent::EventTime.now, {"message" => "This is a test message."})
|
111
|
+
end
|
54
112
|
end
|
55
113
|
|
56
|
-
|
57
|
-
|
114
|
+
assert_equal 1, in_driver.events.length
|
115
|
+
|
116
|
+
tag, _, msg = in_driver.events[0]
|
117
|
+
|
118
|
+
expected_facility = "user"
|
119
|
+
expected_severity = data[:expected_severity] || data[:severity]
|
120
|
+
assert_equal("tag.#{expected_facility}.#{expected_severity}", tag)
|
121
|
+
assert_equal("foo.com", msg["host"])
|
122
|
+
assert_equal("minitest", msg["ident"])
|
123
|
+
assert_equal("This is a test message.", msg["message"])
|
124
|
+
end
|
58
125
|
|
59
|
-
|
60
|
-
|
126
|
+
data("emerg", {in: "emerg", out: "emerg"})
|
127
|
+
data("alert", {in: "alert", out: "alert"})
|
128
|
+
data("crit", {in: "crit", out: "crit"})
|
129
|
+
data("err", {in: "err", out: "err"})
|
130
|
+
data("warn", {in: "warn", out: "warn"})
|
131
|
+
data("warning", {in: "warning", out: "warn"})
|
132
|
+
data("notice", {in: "notice", out: "notice"})
|
133
|
+
data("info", {in: "info", out: "info"})
|
134
|
+
data("debug", {in: "debug", out: "debug"})
|
135
|
+
data("wrong", {in: "wrong", out: "wrong"})
|
136
|
+
def test_severity_mapper(data)
|
137
|
+
out = Fluent::Plugin::RemoteSyslogOutput::SeverityMapper.map(data[:in])
|
138
|
+
assert_equal(data[:out], out)
|
61
139
|
end
|
62
140
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'test/unit'
|
3
|
+
|
1
4
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
2
5
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
6
|
|
4
|
-
require "minitest/autorun"
|
5
|
-
require "minitest/unit"
|
6
|
-
require "minitest/pride"
|
7
7
|
require "fluent/test"
|
8
|
+
require 'fluent/test/driver/output'
|
9
|
+
|
10
|
+
require 'test/unit/rr'
|
metadata
CHANGED
@@ -1,45 +1,46 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-remote_syslog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Lee
|
8
|
+
- Daijiro Fukuda
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2022-09-29 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
15
|
+
name: bundler
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
16
17
|
requirements:
|
17
18
|
- - "~>"
|
18
19
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
+
version: '2.0'
|
20
21
|
type: :development
|
21
22
|
prerelease: false
|
22
23
|
version_requirements: !ruby/object:Gem::Requirement
|
23
24
|
requirements:
|
24
25
|
- - "~>"
|
25
26
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
27
|
+
version: '2.0'
|
27
28
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
29
|
+
name: rake
|
29
30
|
requirement: !ruby/object:Gem::Requirement
|
30
31
|
requirements:
|
31
|
-
- - "
|
32
|
+
- - "~>"
|
32
33
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
+
version: '13.0'
|
34
35
|
type: :development
|
35
36
|
prerelease: false
|
36
37
|
version_requirements: !ruby/object:Gem::Requirement
|
37
38
|
requirements:
|
38
|
-
- - "
|
39
|
+
- - "~>"
|
39
40
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
+
version: '13.0'
|
41
42
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
43
|
+
name: test-unit
|
43
44
|
requirement: !ruby/object:Gem::Requirement
|
44
45
|
requirements:
|
45
46
|
- - ">="
|
@@ -53,27 +54,13 @@ dependencies:
|
|
53
54
|
- !ruby/object:Gem::Version
|
54
55
|
version: '0'
|
55
56
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: fluent-mixin-plaintextformatter
|
57
|
+
name: test-unit-rr
|
71
58
|
requirement: !ruby/object:Gem::Requirement
|
72
59
|
requirements:
|
73
60
|
- - ">="
|
74
61
|
- !ruby/object:Gem::Version
|
75
62
|
version: '0'
|
76
|
-
type: :
|
63
|
+
type: :development
|
77
64
|
prerelease: false
|
78
65
|
version_requirements: !ruby/object:Gem::Requirement
|
79
66
|
requirements:
|
@@ -81,21 +68,7 @@ dependencies:
|
|
81
68
|
- !ruby/object:Gem::Version
|
82
69
|
version: '0'
|
83
70
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 1.0.0
|
90
|
-
type: :runtime
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 1.0.0
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: fluent-mixin-config-placeholders
|
71
|
+
name: fluentd
|
99
72
|
requirement: !ruby/object:Gem::Requirement
|
100
73
|
requirements:
|
101
74
|
- - ">="
|
@@ -109,26 +82,28 @@ dependencies:
|
|
109
82
|
- !ruby/object:Gem::Version
|
110
83
|
version: '0'
|
111
84
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
85
|
+
name: remote_syslog_sender
|
113
86
|
requirement: !ruby/object:Gem::Requirement
|
114
87
|
requirements:
|
115
88
|
- - ">="
|
116
89
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
90
|
+
version: 1.1.1
|
118
91
|
type: :runtime
|
119
92
|
prerelease: false
|
120
93
|
version_requirements: !ruby/object:Gem::Requirement
|
121
94
|
requirements:
|
122
95
|
- - ">="
|
123
96
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
97
|
+
version: 1.1.1
|
125
98
|
description: ''
|
126
99
|
email:
|
127
100
|
- dlackty@gmail.com
|
101
|
+
- fukuda@clear-code.com
|
128
102
|
executables: []
|
129
103
|
extensions: []
|
130
104
|
extra_rdoc_files: []
|
131
105
|
files:
|
106
|
+
- ".github/workflows/test.yaml"
|
132
107
|
- ".gitignore"
|
133
108
|
- ".travis.yml"
|
134
109
|
- CHANGELOG.md
|
@@ -160,8 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
135
|
- !ruby/object:Gem::Version
|
161
136
|
version: '0'
|
162
137
|
requirements: []
|
163
|
-
|
164
|
-
rubygems_version: 2.6.10
|
138
|
+
rubygems_version: 3.1.6
|
165
139
|
signing_key:
|
166
140
|
specification_version: 4
|
167
141
|
summary: Fluentd output plugin for remote syslog
|