fluent-plugin-syslog_rfc5424 0.7.0 → 0.7.1.alpha1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f6c2a7e27ac573735e5cdfb190c0ebe9b5be330b
4
- data.tar.gz: 6c8c1dd62b0dac4917b751e2458a21dee022aa52
3
+ metadata.gz: 4f20adbe28656d64f9ad85d6ef642df03387a153
4
+ data.tar.gz: 80af7c193d2aad826f2d44f7d1adc9f1fd5658b7
5
5
  SHA512:
6
- metadata.gz: c7766465f1c7aa0f37e4e67cdc3eda168b1808ca8e1aada5b42c6fa26e2319ab6ca0dde93bc3616ef72fa87a0423196139e40bd90573e62b2ac4d06fe01d2ee8
7
- data.tar.gz: '0238772ac572669f1194d68cf0b9e65d1108bbbc3a0ca08d88def67863de93aab8fd1de83ff23bd91ef31c983c3e8226d3111dcd5fc85d2ebd3ce578c56729f6'
6
+ metadata.gz: 21473d51186b0512828bcb3981a723e7479d762804aa84627388193a46a2bd0b743e7ef6197109b1024ef9f6c4f8291985d88fcc35d3f36cfb306234c4742c84
7
+ data.tar.gz: 2867cc9f1b2e9274bad415149e7e4faa567eca8eafa4606cad6f469f5ce5139d1fa43fd6bc4cf385b353eb5f9b296cc6c553677887a783ca2a36ea4f528e2fb9
data/.gitignore CHANGED
@@ -11,4 +11,7 @@
11
11
  # rspec failure tracking
12
12
  .rspec_status
13
13
 
14
+ #binary
15
+ fluent-plugin-syslog_rfc5424-*.gem
16
+
14
17
  Gemfile.lock
data/README.md CHANGED
@@ -39,11 +39,13 @@ Or install it yourself as:
39
39
 
40
40
  ### Configuration
41
41
 
42
- | name | type | placeholder support | description |
43
- | -------------- | ------- | ----------- | --------------------------------- |
44
- | host | string | | syslog target host |
45
- | port | integer | | syslog target port |
46
- | transport | string | | transport protocol (tls [default], udp, or tcp) |
42
+ | name | type | description |
43
+ | -------------- | ------- | --------------------------------- |
44
+ | host | string | syslog target host |
45
+ | port | integer | syslog target port |
46
+ | transport | string | transport protocol (tls [default], udp, or tcp) |
47
+ | insecure | boolean | skip ssl validation |
48
+ | trusted_ca_path | string | file path to ca to trust |
47
49
 
48
50
  #### Format Section
49
51
 
@@ -52,25 +54,23 @@ Defaults to `syslog_rfc5424`
52
54
  | name |type | description |
53
55
  | -------------- | ------- | ------- |
54
56
  | rfc6587_message_size | boolean | prepends message length for syslog transmission (true by default) |
57
+ | app_name_field | string | sets app name in syslog from field in fluentd, delimited by '.' (default app_name) |
58
+ | proc_id_field | string | sets proc id in syslog from field in fluentd, delimited by '.' (default proc_id) |
55
59
 
56
60
 
57
61
  ## Formatter Usage
58
62
 
59
63
  ```
60
64
  <match **>
61
- @type example
65
+ @type syslog_rfc5424
62
66
  <format>
63
67
  @type syslog_rfc5424
68
+ app_name_field example.custom_field_1
69
+ proc_id_field example.custom_field_2
64
70
  </format>
65
71
  </match>
66
72
  ```
67
73
 
68
- ### Configuration
69
-
70
- | name |type | description |
71
- | -------------- | ------- | ------- |
72
- | rfc6587_message_size | boolean | prepends message length for syslog transmission (false by default) |
73
-
74
74
 
75
75
  ## Development
76
76
 
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "fluent-plugin-syslog_rfc5424"
7
- spec.version = "0.7.0"
7
+ spec.version = "0.7.1.alpha1"
8
8
  spec.authors = ["Pivotal"]
9
9
  spec.email = %w(cf-loggregator@pivotal.io)
10
10
  spec.homepage = "https://github.com/cloudfoundry/fluent-plugin-syslog_rfc5424"
@@ -5,7 +5,7 @@ module Fluent
5
5
  class FormatterSyslogRFC5424 < Formatter
6
6
  Fluent::Plugin.register_formatter('syslog_rfc5424', self)
7
7
 
8
- config_param :rfc6587_message_size, :bool, default: false
8
+ config_param :rfc6587_message_size, :bool, default: true
9
9
  config_param :app_name_field, :string, default: "app_name"
10
10
  config_param :proc_id_field, :string, default: "proc_id"
11
11
 
@@ -33,7 +33,7 @@ module Fluent
33
33
  log.debug(msg)
34
34
 
35
35
  return msg unless @rfc6587_message_size
36
-
36
+ msg.delete!("\n")
37
37
  msg.length.to_s + ' ' + msg
38
38
  end
39
39
  end
@@ -15,7 +15,6 @@ module Fluent
15
15
  config_param :trusted_ca_path, :string, default: nil
16
16
  config_section :format do
17
17
  config_set_default :@type, DEFAULT_FORMATTER
18
- config_set_default :rfc6587_message_size, true
19
18
  end
20
19
 
21
20
  def configure(config)
@@ -28,7 +27,12 @@ module Fluent
28
27
  socket = find_or_create_socket(@transport.to_sym, @host, @port)
29
28
  tag = chunk.metadata.tag
30
29
  chunk.each do |time, record|
31
- socket.puts @formatter.format(tag, time, record)
30
+ begin
31
+ socket.puts @formatter.format(tag, time, record)
32
+ rescue
33
+ @sockets[socket_key(@transport.to_sym, @host, @port)] = nil
34
+ raise
35
+ end
32
36
  end
33
37
  end
34
38
 
@@ -13,6 +13,7 @@ class FormatterSyslogRFC5424Test < Test::Unit::TestCase
13
13
  def test_format_default
14
14
  formatter_driver = create_driver %(
15
15
  @type syslog_rfc5424
16
+ rfc6587_message_size false
16
17
  )
17
18
  tag = "test-formatter"
18
19
  time = Fluent::EventTime.new(0, 123456000)
@@ -48,10 +49,26 @@ class FormatterSyslogRFC5424Test < Test::Unit::TestCase
48
49
  formatter_driver.instance.format(tag, time, record)
49
50
  end
50
51
 
52
+ def test_format_with_message_size_and_new_line
53
+ formatter_driver = create_driver %(
54
+ @type syslog_rfc5424
55
+ rfc6587_message_size true
56
+ )
57
+ tag = "test-formatter"
58
+ time = Fluent::EventTime.new(0, 123456000)
59
+ record = {"log" => "test-log\n\n"}
60
+
61
+ formatted_message = "<14>1 1970-01-01T00:00:00.123456+00:00 - - - - - test-log"
62
+ message_size = formatted_message.length
63
+ assert_equal "#{message_size} #{formatted_message}",
64
+ formatter_driver.instance.format(tag, time, record)
65
+ end
66
+
51
67
  def test_format_with_app_name
52
68
  formatter_driver = create_driver %(
53
69
  @type syslog_rfc5424
54
70
  app_name_field example.custom_field
71
+ rfc6587_message_size false
55
72
  )
56
73
  tag = "test-formatter"
57
74
  time = Fluent::EventTime.new(0, 123456000)
@@ -67,6 +84,7 @@ class FormatterSyslogRFC5424Test < Test::Unit::TestCase
67
84
  formatter_driver = create_driver %(
68
85
  @type syslog_rfc5424
69
86
  proc_id_field example.custom_field
87
+ rfc6587_message_size false
70
88
  )
71
89
  tag = "test-formatter"
72
90
  time = Fluent::EventTime.new(0, 123456000)
@@ -43,6 +43,34 @@ class OutSyslogRFC5424Test < Test::Unit::TestCase
43
43
  end
44
44
  end
45
45
 
46
+ def test_reconnects
47
+ output_driver = create_driver %(
48
+ @type syslog_rfc5424
49
+ host example.com
50
+ port 123
51
+ )
52
+
53
+ bad_socket = Minitest::Mock.new
54
+ mock(bad_socket).puts(@formatted_log) {
55
+ raise StandardError
56
+ }
57
+ stub(bad_socket).close
58
+
59
+
60
+ good_socket = Minitest::Mock.new
61
+ mock(good_socket).puts(@formatted_log)
62
+ stub(good_socket).close
63
+
64
+ any_instance_of(Fluent::Plugin::OutSyslogRFC5424) do |fluent_plugin|
65
+ mock(fluent_plugin).socket_create(:tls, "example.com", 123, {:insecure=>false, :verify_fqdn=>true, :cert_paths=>nil}).returns(bad_socket)
66
+ mock(fluent_plugin).socket_create(:tls, "example.com", 123, {:insecure=>false, :verify_fqdn=>true, :cert_paths=>nil}).returns(good_socket)
67
+ end
68
+
69
+ output_driver.run(shutdown: false, force_flush_retry: true) do
70
+ output_driver.feed("tag", @time, {"log" => "hi"})
71
+ end
72
+ end
73
+
46
74
  def test_non_tls
47
75
  output_driver = create_driver %(
48
76
  @type syslog_rfc5424
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-syslog_rfc5424
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1.alpha1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pivotal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-17 00:00:00.000000000 Z
11
+ date: 2020-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -145,9 +145,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
145
  version: '0'
146
146
  required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  requirements:
148
- - - ">="
148
+ - - ">"
149
149
  - !ruby/object:Gem::Version
150
- version: '0'
150
+ version: 1.3.1
151
151
  requirements: []
152
152
  rubyforge_project:
153
153
  rubygems_version: 2.6.13