fluent-plugin-syslog_rfc5424 0.7.3.pre.rc.13 → 0.7.3.pre.rc.14

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
  SHA256:
3
- metadata.gz: f7acf509e9410bf4b84bd9d6b171c2c265118b57aec02e92bd18694be1d96d1e
4
- data.tar.gz: 30690a976fcbf29abc3489b6b8840cbe49b620a32282df9b3ec6f1fe459f6012
3
+ metadata.gz: 3f3898feebffff9f054054d6389e71b31d47c9555ae2773ef52e1357615d36c5
4
+ data.tar.gz: 17a959dfa916bac88c3b03397dc9ecc070a00dcab19b2e54566bc56591fd4b43
5
5
  SHA512:
6
- metadata.gz: 25837f25d6f7ae52d6f1078411f4d2d90fe23a72db113bd79991bca6e9393eeae0a8d0040b44caacec28b7602e4dce8944122fc1a355180b793fb82433856d8c
7
- data.tar.gz: bebcbfcb3cc3a3aed501181786d674f19d1c5659ceb1980c182e0ea6a8148265e6eda2476ea49fea7244cabb84a876eb87c5bb723e9db81ce6f3ba28760ef6a8
6
+ metadata.gz: 041d7a2b70697aa88c6346b41712daaf7ee120f9a00793c7808a5d456aca04e29e5ed6e44e093488376973f865d3b7d52bb6f5ef9429a5586e89bbbdb91e674e
7
+ data.tar.gz: a00ca75526947ad4e8c6966859f87155dc8d589612165dd978e86ec8d860abcd95880047f11ebf63ba92d82d94e609b778abf83420f8da1ede49e7c8135f1068
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.4.2
1
+ 2.5.7
@@ -6,13 +6,21 @@ module Fluent
6
6
  Fluent::Plugin.register_formatter('syslog_rfc5424', self)
7
7
 
8
8
  config_param :rfc6587_message_size, :bool, default: true
9
+ config_param :hostname_field, :string, default: "hostname"
9
10
  config_param :app_name_field, :string, default: "app_name"
10
11
  config_param :proc_id_field, :string, default: "proc_id"
12
+ config_param :message_id_field, :string, default: "message_id"
13
+ config_param :structured_data_field, :string, default: "structured_data"
14
+ config_param :log_field, :string, default: "log"
11
15
 
12
16
  def configure(conf)
13
17
  super
18
+ @hostname_field_array = @hostname_field.split(".")
14
19
  @app_name_field_array = @app_name_field.split(".")
15
20
  @proc_id_field_array = @proc_id_field.split(".")
21
+ @message_id_field_array = @message_id_field.split(".")
22
+ @structured_data_field_array = @structured_data_field.split(".")
23
+ @log_field_array = @log_field.split(".")
16
24
  end
17
25
 
18
26
  def format(tag, time, record)
@@ -20,10 +28,13 @@ module Fluent
20
28
  log.debug(record.map { |k, v| "#{k}=#{v}" }.join('&'))
21
29
 
22
30
  msg = RFC5424::Formatter.format(
23
- log: record['log'],
31
+ log: record.dig(*@log_field_array) || "-",
24
32
  timestamp: time,
33
+ hostname: record.dig(*@hostname_field_array) || "-",
25
34
  app_name: record.dig(*@app_name_field_array) || "-",
26
- proc_id: record.dig(*@proc_id_field_array) || "-"
35
+ proc_id: record.dig(*@proc_id_field_array) || "-",
36
+ msg_id: record.dig(*@message_id_field_array) || "-",
37
+ sd: record.dig(*@structured_data_field_array) || "-"
27
38
  )
28
39
 
29
40
  log.debug("RFC 5424 Message")
@@ -35,4 +46,4 @@ module Fluent
35
46
  end
36
47
  end
37
48
  end
38
- end
49
+ end
@@ -1,3 +1,3 @@
1
1
  module FluentSyslog5424OutputPlugin
2
- VERSION = "0.7.3-rc.13"
2
+ VERSION = "0.7.3-rc.14"
3
3
  end
@@ -65,6 +65,54 @@ class FormatterSyslogRFC5424Test < Test::Unit::TestCase
65
65
  formatter_driver.instance.format(tag, time, record)
66
66
  end
67
67
 
68
+ def test_format_with_log_field
69
+ formatter_driver = create_driver %(
70
+ @type syslog_rfc5424
71
+ rfc6587_message_size false
72
+ log_field example.custom_field
73
+ )
74
+ tag = "test-formatter"
75
+ time = Fluent::EventTime.new(0, 123456000)
76
+ record = {"log" => "test-log", "example" => {"custom_field" => "custom-value"}}
77
+
78
+ formatted_message = "<14>1 1970-01-01T00:00:00.123456+00:00 - - - - - custom-value\n"
79
+ message_size = formatted_message.length
80
+ assert_equal "#{formatted_message}",
81
+ formatter_driver.instance.format(tag, time, record)
82
+ end
83
+
84
+ def test_format_with_structured_data
85
+ formatter_driver = create_driver %(
86
+ @type syslog_rfc5424
87
+ rfc6587_message_size false
88
+ structured_data_field example.custom_field
89
+ )
90
+ tag = "test-formatter"
91
+ time = Fluent::EventTime.new(0, 123456000)
92
+ record = {"log" => "test-log", "example" => {"custom_field" => "custom-value"}}
93
+
94
+ formatted_message = "<14>1 1970-01-01T00:00:00.123456+00:00 - - - - custom-value test-log\n"
95
+ message_size = formatted_message.length
96
+ assert_equal "#{formatted_message}",
97
+ formatter_driver.instance.format(tag, time, record)
98
+ end
99
+
100
+ def test_format_with_hostname
101
+ formatter_driver = create_driver %(
102
+ @type syslog_rfc5424
103
+ rfc6587_message_size false
104
+ hostname_field example.custom_field
105
+ )
106
+ tag = "test-formatter"
107
+ time = Fluent::EventTime.new(0, 123456000)
108
+ record = {"log" => "test-log", "example" => {"custom_field" => "custom-value"}}
109
+
110
+ formatted_message = "<14>1 1970-01-01T00:00:00.123456+00:00 custom-value - - - - test-log\n"
111
+ message_size = formatted_message.length
112
+ assert_equal "#{formatted_message}",
113
+ formatter_driver.instance.format(tag, time, record)
114
+ end
115
+
68
116
  def test_format_with_proc_id
69
117
  formatter_driver = create_driver %(
70
118
  @type syslog_rfc5424
@@ -81,5 +129,20 @@ class FormatterSyslogRFC5424Test < Test::Unit::TestCase
81
129
  formatter_driver.instance.format(tag, time, record)
82
130
  end
83
131
 
132
+ def test_format_with_message_id
133
+ formatter_driver = create_driver %(
134
+ @type syslog_rfc5424
135
+ rfc6587_message_size false
136
+ message_id_field example.custom_field
137
+ )
138
+ tag = "test-formatter"
139
+ time = Fluent::EventTime.new(0, 123456000)
140
+ record = {"log" => "test-log", "example" => {"custom_field" => "custom-value"}}
141
+
142
+ formatted_message = "<14>1 1970-01-01T00:00:00.123456+00:00 - - - custom-value - test-log\n"
143
+ message_size = formatted_message.length
144
+ assert_equal "#{formatted_message}",
145
+ formatter_driver.instance.format(tag, time, record)
146
+ end
84
147
 
85
- end
148
+ end
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.3.pre.rc.13
4
+ version: 0.7.3.pre.rc.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pivotal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-02 00:00:00.000000000 Z
11
+ date: 2020-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler