fluent-plugin-remote_syslog_multiline 1.0.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 180fbce858c4fbb8cf9216ab3ad30aded4ab7c5a
4
+ data.tar.gz: f9312dcaf78a7cb1f04a2fa8908077bf80d53b77
5
+ SHA512:
6
+ metadata.gz: f32b13a75d118bfa356ea8176f5383b2c1bdf7eb3bd48693ca2f64cd7529b698d3c829c29043f0eee406556de10236c4038857beb4f2243482f68c883308e385
7
+ data.tar.gz: e50fb00dc990de3ab7a0e33be31d1297fa576fc3406c3cca4a5cb7c5971b2aee1ef94bac9bb4d10eaad4204c6f6d324349cf8e865fda5a5b1e357dfd3413922b
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ sudo: false
3
+ cache: bundler
4
+ rvm:
5
+ - 2.1.10
6
+ - 2.2.5
7
+ - 2.3.1
8
+ - 2.4.1
9
+ before_install:
10
+ - gem update bundler
@@ -0,0 +1,35 @@
1
+ ## 1.0.0
2
+
3
+ * Support fluentd-0.14 or later features [#24](https://github.com/dlackty/fluent-plugin-remote_syslog/pull/24)
4
+ * Support TCP and TLS protocol [#24](https://github.com/dlackty/fluent-plugin-remote_syslog/pull/24)
5
+ * Not support fluentd-0.12.0 from this version
6
+
7
+ ## 0.3.3
8
+
9
+ * Allow override "severity" or "facility" from records [#19](https://github.com/dlackty/fluent-plugin-remote_syslog/pull/19)
10
+ * Change default port to 514 [#15](https://github.com/dlackty/fluent-plugin-remote_syslog/pull/15)
11
+
12
+ ## 0.3.2
13
+
14
+ * Rewrite plugin to make rewrite tag function work properly [#4](https://github.com/dlackty/fluent-plugin-remote_syslog/pull/4)
15
+
16
+ ## 0.3.1
17
+
18
+ * Fix errors in last release [#3](https://github.com/dlackty/fluent-plugin-remote_syslog/pull/3)
19
+
20
+ ## 0.3.0 (yanked)
21
+
22
+ * Integrate with `Fluent::Mixin::RewriteTagName` [#2](https://github.com/dlackty/fluent-plugin-remote_syslog/pull/2)
23
+
24
+ ## 0.2.1
25
+
26
+ * Fix encoding issue
27
+
28
+ ## 0.2.0
29
+
30
+ * Integrate with `Fluent::Mixin::PlainTextFormatter`
31
+ * **BREAKING**: Remove `key_name` config, use `output_data_type` instead
32
+
33
+ ## 0.1.0
34
+
35
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fluent-plugin-remote_syslog.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Richard Lee
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,83 @@
1
+ # fluent-plugin-remote_syslog
2
+
3
+ [![Build Status](https://travis-ci.org/dlackty/fluent-plugin-remote_syslog.svg?branch=master)](https://travis-ci.org/dlackty/fluent-plugin-remote_syslog)
4
+
5
+ [Fluentd](http://fluentd.org) plugin for output to remote syslog serivce (e.g. [Papertrail](http://papertrailapp.com/))
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
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ fluent-gem install fluent-plugin-remote_syslog
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ ```
23
+ <match foo.bar>
24
+ @type remote_syslog
25
+ host example.com
26
+ port 514
27
+ severity debug
28
+ program fluentd
29
+ hostname ${tag[1]}
30
+
31
+ <buffer tag>
32
+ </buffer>
33
+
34
+ <format>
35
+ @type single_value
36
+ message_key msg
37
+ </format>
38
+ </match>
39
+ ```
40
+
41
+ ## Configuration
42
+
43
+ | name | type | placeholder support | description |
44
+ | -------------- | ------- | ----------- | --------------------------------- |
45
+ | hostname | string | support | departure of log |
46
+ | host | string | support | syslog target host |
47
+ | port | integer (default: `514`) | | syslog target port |
48
+ | host_with_port | string | support | parameter for <host>:<port> style |
49
+ | facility | string (default: `"user"`) | support | syslog facility |
50
+ | severity | string (default: `"notice"` | support | syslog severity |
51
+ | program | string (default: `"fluentd"` | support | syslog program name |
52
+ | protocol | enum (udp, tcp) (default: `udp`) | | transfer protocol |
53
+ | tls | bool (default: false) | | use TLS (tcp only) |
54
+ | ca_file | string | | ca_file path (tls mode only) |
55
+ | verify_mode | integer | | SSL verification mode (tls mode only) |
56
+ | packet_size | integer (default: `1024`) | | size limitation for syslog packet |
57
+ | timeout | integer | | TCP transfer timeout. if value is 0, wait forever |
58
+ | timeout_exception | bool (default: `false`) | | if value is true, raise exception by transfer timeout |
59
+ | keep_alive | bool (default: `false`) | | use TCP keep alive |
60
+ | keep_alive_idle | integer | | set TCP keep alive idle time |
61
+ | keep_alive_cnt | integer | | set TCP keep alive probe count |
62
+ | keep_alive_intvl | integer | | set TCP keep alive probe interval |
63
+
64
+ ### Common Configuration
65
+
66
+ #### Buffer Section
67
+
68
+ | name | default |
69
+ | -------------- | ------- |
70
+ | flush_mode | interval |
71
+ | flush_interval | 5 |
72
+ | flush_thread_interval | 0.5 |
73
+ | flush_thread_burst_interval | 0.5 |
74
+
75
+ #### Format Section
76
+
77
+ | name | default |
78
+ | -------------- | ------- |
79
+ | @type | ltsv |
80
+
81
+ ## License
82
+
83
+ Copyright (c) 2014-2017 Richard Lee. See LICENSE for details.
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+ Rake::TestTask.new(:test) do |test|
5
+ test.libs << "lib" << "test"
6
+ test.pattern = "test/plugin/*.rb"
7
+ test.verbose = true
8
+ end
9
+
10
+ task :default => :test
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "fluent-plugin-remote_syslog_multiline"
7
+ spec.version = File.read("VERSION").strip
8
+ spec.authors = ["Lawrence Li","Richard Lee"]
9
+ spec.email = ["lawrleegle@gmail.com"]
10
+ spec.summary = %q{Fluentd output plugin for remote syslog}
11
+ spec.description = spec.description
12
+ spec.homepage = "https://github.com/gitlawr/fluent-plugin-remote_syslog"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_development_dependency "rake", "~> 10.0"
20
+ spec.add_development_dependency "test-unit"
21
+ spec.add_development_dependency "test-unit-rr"
22
+
23
+ spec.add_runtime_dependency "fluentd"
24
+ spec.add_runtime_dependency "remote_syslog_sender", ">= 1.1.1"
25
+ end
@@ -0,0 +1,153 @@
1
+ require "remote_syslog_sender"
2
+
3
+ module Fluent
4
+ module Plugin
5
+ class RemoteSyslogOutput < Output
6
+ Fluent::Plugin.register_output("remote_syslog", self)
7
+
8
+ helpers :formatter, :inject
9
+
10
+ config_param :hostname, :string, :default => ""
11
+
12
+ config_param :host, :string, :default => nil
13
+ config_param :port, :integer, :default => 514
14
+ config_param :host_with_port, :string, :default => nil
15
+
16
+ config_param :facility, :string, :default => "user"
17
+ config_param :severity, :string, :default => "notice"
18
+ config_param :program, :string, :default => "fluentd"
19
+
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
27
+
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
73
+
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
+ packet_options = {facility: facility, severity: severity, program: program}
100
+ packet_options[:hostname] = hostname unless hostname.empty?
101
+
102
+ begin
103
+ chunk.open do |io|
104
+ msg = io.read
105
+ sender.transmit(msg.chomp!, packet_options)
106
+ end
107
+ rescue
108
+ if Thread.current[host_with_port]
109
+ Thread.current[host_with_port].close
110
+ @senders.delete(Thread.current[host_with_port])
111
+ Thread.current[host_with_port] = nil
112
+ end
113
+ raise
114
+ end
115
+ end
116
+
117
+ private
118
+
119
+ def create_sender(host, port)
120
+ if @protocol == :tcp
121
+ options = {
122
+ tls: @tls,
123
+ whinyerrors: true,
124
+ packet_size: @packet_size,
125
+ timeout: @timeout,
126
+ timeout_exception: @timeout_exception,
127
+ keep_alive: @keep_alive,
128
+ keep_alive_idle: @keep_alive_idle,
129
+ keep_alive_cnt: @keep_alive_cnt,
130
+ keep_alive_intvl: @keep_alive_intvl,
131
+ program: @program,
132
+ }
133
+ options[:ca_file] = @ca_file if @ca_file
134
+ options[:verify_mode] = @verify_mode if @verify_mode
135
+ sender = RemoteSyslogSender::TcpSender.new(
136
+ host,
137
+ port,
138
+ options
139
+ )
140
+ else
141
+ sender = RemoteSyslogSender::UdpSender.new(
142
+ host,
143
+ port,
144
+ whinyerrors: true,
145
+ program: @program,
146
+ )
147
+ end
148
+ @senders << sender
149
+ sender
150
+ end
151
+ end
152
+ end
153
+ end
@@ -0,0 +1,84 @@
1
+ require "test_helper"
2
+ require "fluent/plugin/out_remote_syslog"
3
+
4
+ class RemoteSyslogOutputTest < Test::Unit::TestCase
5
+ def setup
6
+ Fluent::Test.setup
7
+ end
8
+
9
+ def create_driver(conf = CONFIG)
10
+ Fluent::Test::Driver::Output.new(Fluent::Plugin::RemoteSyslogOutput).configure(conf)
11
+ end
12
+
13
+ def test_configure
14
+ d = create_driver %[
15
+ @type remote_syslog
16
+ hostname foo.com
17
+ host example.com
18
+ port 5566
19
+ severity debug
20
+ program minitest
21
+ ]
22
+
23
+ loggers = d.instance.instance_variable_get(:@senders)
24
+ assert_equal loggers, []
25
+
26
+ assert_equal "example.com", d.instance.instance_variable_get(:@host)
27
+ assert_equal 5566, d.instance.instance_variable_get(:@port)
28
+ assert_equal "debug", d.instance.instance_variable_get(:@severity)
29
+ end
30
+
31
+ def test_write
32
+ d = create_driver %[
33
+ @type remote_syslog
34
+ hostname foo.com
35
+ host example.com
36
+ port 5566
37
+ severity debug
38
+ program minitest
39
+
40
+ <format>
41
+ @type single_value
42
+ message_key message
43
+ </format>
44
+ ]
45
+
46
+ mock.proxy(RemoteSyslogSender::UdpSender).new("example.com", 5566, whinyerrors: true, program: "minitest") do |sender|
47
+ mock.proxy(sender).transmit("foo", facility: "user", severity: "debug", program: "minitest", hostname: "foo.com")
48
+ end
49
+
50
+ d.run do
51
+ d.feed("tag", Fluent::EventTime.now, {"message" => "foo"})
52
+ end
53
+ end
54
+
55
+ def test_write_tcp
56
+ d = create_driver %[
57
+ @type remote_syslog
58
+ hostname foo.com
59
+ host example.com
60
+ port 5566
61
+ severity debug
62
+ program minitest
63
+
64
+ protocol tcp
65
+
66
+ <format>
67
+ @type single_value
68
+ message_key message
69
+ </format>
70
+ ]
71
+
72
+ any_instance_of(RemoteSyslogSender::TcpSender) do |klass|
73
+ mock(klass).connect
74
+ end
75
+
76
+ mock.proxy(RemoteSyslogSender::TcpSender).new("example.com", 5566, whinyerrors: true, program: "minitest", tls: false, packet_size: 1024, timeout: nil, timeout_exception: false, keep_alive: false, keep_alive_cnt: nil, keep_alive_idle: nil, keep_alive_intvl: nil) do |sender|
77
+ mock(sender).transmit("foo", facility: "user", severity: "debug", program: "minitest", hostname: "foo.com")
78
+ end
79
+
80
+ d.run do
81
+ d.feed("tag", Fluent::EventTime.now, {"message" => "foo"})
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,10 @@
1
+ require 'bundler/setup'
2
+ require 'test/unit'
3
+
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
5
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
6
+
7
+ require "fluent/test"
8
+ require 'fluent/test/driver/output'
9
+
10
+ require 'test/unit/rr'
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-remote_syslog_multiline
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Lawrence Li
8
+ - Richard Lee
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2020-06-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '10.0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '10.0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: test-unit
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: test-unit-rr
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: fluentd
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: remote_syslog_sender
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 1.1.1
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: 1.1.1
84
+ description: ''
85
+ email:
86
+ - lawrleegle@gmail.com
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".travis.yml"
93
+ - CHANGELOG.md
94
+ - Gemfile
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - VERSION
99
+ - fluent-plugin-remote_syslog.gemspec
100
+ - lib/fluent/plugin/out_remote_syslog.rb
101
+ - test/plugin/out_remote_syslog.rb
102
+ - test/test_helper.rb
103
+ homepage: https://github.com/gitlawr/fluent-plugin-remote_syslog
104
+ licenses:
105
+ - MIT
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.6.11
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: Fluentd output plugin for remote syslog
127
+ test_files:
128
+ - test/plugin/out_remote_syslog.rb
129
+ - test/test_helper.rb