fluentd 1.17.0-x86-mingw32 → 1.17.1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (259) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +46 -0
  3. data/README.md +1 -0
  4. data/SECURITY.md +2 -2
  5. data/fluent.conf +14 -14
  6. data/lib/fluent/command/cap_ctl.rb +4 -4
  7. data/lib/fluent/compat/call_super_mixin.rb +3 -3
  8. data/lib/fluent/compat/propagate_default.rb +4 -4
  9. data/lib/fluent/config/yaml_parser/parser.rb +4 -0
  10. data/lib/fluent/log/console_adapter.rb +4 -2
  11. data/lib/fluent/plugin/in_exec.rb +14 -2
  12. data/lib/fluent/plugin/in_http.rb +1 -1
  13. data/lib/fluent/plugin/in_sample.rb +13 -7
  14. data/lib/fluent/plugin/in_tail.rb +65 -23
  15. data/lib/fluent/plugin/out_copy.rb +1 -1
  16. data/lib/fluent/plugin/out_file.rb +8 -0
  17. data/lib/fluent/plugin/out_http.rb +12 -0
  18. data/lib/fluent/plugin/parser_json.rb +4 -12
  19. data/lib/fluent/plugin_helper/http_server/server.rb +1 -1
  20. data/lib/fluent/version.rb +1 -1
  21. data/templates/new_gem/fluent-plugin.gemspec.erb +6 -5
  22. metadata +25 -472
  23. data/.github/DISCUSSION_TEMPLATE/q-a-japanese.yml +0 -50
  24. data/.github/DISCUSSION_TEMPLATE/q-a.yml +0 -47
  25. data/.github/ISSUE_TEMPLATE/bug_report.yml +0 -71
  26. data/.github/ISSUE_TEMPLATE/config.yml +0 -5
  27. data/.github/ISSUE_TEMPLATE/feature_request.yml +0 -39
  28. data/.github/ISSUE_TEMPLATE.md +0 -17
  29. data/.github/PULL_REQUEST_TEMPLATE.md +0 -14
  30. data/.github/workflows/stale-actions.yml +0 -24
  31. data/.github/workflows/test-ruby-head.yml +0 -31
  32. data/.github/workflows/test.yml +0 -32
  33. data/.gitignore +0 -30
  34. data/Gemfile +0 -9
  35. data/fluentd.gemspec +0 -62
  36. data/test/command/test_binlog_reader.rb +0 -362
  37. data/test/command/test_ca_generate.rb +0 -70
  38. data/test/command/test_cap_ctl.rb +0 -100
  39. data/test/command/test_cat.rb +0 -128
  40. data/test/command/test_ctl.rb +0 -56
  41. data/test/command/test_fluentd.rb +0 -1291
  42. data/test/command/test_plugin_config_formatter.rb +0 -397
  43. data/test/command/test_plugin_generator.rb +0 -109
  44. data/test/compat/test_calls_super.rb +0 -166
  45. data/test/compat/test_parser.rb +0 -92
  46. data/test/config/assertions.rb +0 -42
  47. data/test/config/test_config_parser.rb +0 -551
  48. data/test/config/test_configurable.rb +0 -1784
  49. data/test/config/test_configure_proxy.rb +0 -604
  50. data/test/config/test_dsl.rb +0 -415
  51. data/test/config/test_element.rb +0 -518
  52. data/test/config/test_literal_parser.rb +0 -309
  53. data/test/config/test_plugin_configuration.rb +0 -56
  54. data/test/config/test_section.rb +0 -191
  55. data/test/config/test_system_config.rb +0 -195
  56. data/test/config/test_types.rb +0 -408
  57. data/test/counter/test_client.rb +0 -563
  58. data/test/counter/test_error.rb +0 -44
  59. data/test/counter/test_mutex_hash.rb +0 -179
  60. data/test/counter/test_server.rb +0 -589
  61. data/test/counter/test_store.rb +0 -258
  62. data/test/counter/test_validator.rb +0 -137
  63. data/test/helper.rb +0 -155
  64. data/test/helpers/fuzzy_assert.rb +0 -89
  65. data/test/helpers/process_extenstion.rb +0 -33
  66. data/test/log/test_console_adapter.rb +0 -117
  67. data/test/plugin/data/2010/01/20100102-030405.log +0 -0
  68. data/test/plugin/data/2010/01/20100102-030406.log +0 -0
  69. data/test/plugin/data/2010/01/20100102.log +0 -0
  70. data/test/plugin/data/log/bar +0 -0
  71. data/test/plugin/data/log/foo/bar.log +0 -0
  72. data/test/plugin/data/log/foo/bar2 +0 -0
  73. data/test/plugin/data/log/test.log +0 -0
  74. data/test/plugin/data/log_numeric/01.log +0 -0
  75. data/test/plugin/data/log_numeric/02.log +0 -0
  76. data/test/plugin/data/log_numeric/12.log +0 -0
  77. data/test/plugin/data/log_numeric/14.log +0 -0
  78. data/test/plugin/data/sd_file/config +0 -11
  79. data/test/plugin/data/sd_file/config.json +0 -17
  80. data/test/plugin/data/sd_file/config.yaml +0 -11
  81. data/test/plugin/data/sd_file/config.yml +0 -11
  82. data/test/plugin/data/sd_file/invalid_config.yml +0 -7
  83. data/test/plugin/in_tail/test_fifo.rb +0 -121
  84. data/test/plugin/in_tail/test_io_handler.rb +0 -150
  85. data/test/plugin/in_tail/test_position_file.rb +0 -346
  86. data/test/plugin/out_forward/test_ack_handler.rb +0 -140
  87. data/test/plugin/out_forward/test_connection_manager.rb +0 -145
  88. data/test/plugin/out_forward/test_handshake_protocol.rb +0 -112
  89. data/test/plugin/out_forward/test_load_balancer.rb +0 -106
  90. data/test/plugin/out_forward/test_socket_cache.rb +0 -174
  91. data/test/plugin/test_bare_output.rb +0 -131
  92. data/test/plugin/test_base.rb +0 -247
  93. data/test/plugin/test_buf_file.rb +0 -1314
  94. data/test/plugin/test_buf_file_single.rb +0 -898
  95. data/test/plugin/test_buf_memory.rb +0 -42
  96. data/test/plugin/test_buffer.rb +0 -1493
  97. data/test/plugin/test_buffer_chunk.rb +0 -209
  98. data/test/plugin/test_buffer_file_chunk.rb +0 -871
  99. data/test/plugin/test_buffer_file_single_chunk.rb +0 -611
  100. data/test/plugin/test_buffer_memory_chunk.rb +0 -339
  101. data/test/plugin/test_compressable.rb +0 -87
  102. data/test/plugin/test_file_util.rb +0 -96
  103. data/test/plugin/test_filter.rb +0 -368
  104. data/test/plugin/test_filter_grep.rb +0 -697
  105. data/test/plugin/test_filter_parser.rb +0 -731
  106. data/test/plugin/test_filter_record_transformer.rb +0 -577
  107. data/test/plugin/test_filter_stdout.rb +0 -207
  108. data/test/plugin/test_formatter_csv.rb +0 -136
  109. data/test/plugin/test_formatter_hash.rb +0 -38
  110. data/test/plugin/test_formatter_json.rb +0 -61
  111. data/test/plugin/test_formatter_ltsv.rb +0 -70
  112. data/test/plugin/test_formatter_msgpack.rb +0 -28
  113. data/test/plugin/test_formatter_out_file.rb +0 -116
  114. data/test/plugin/test_formatter_single_value.rb +0 -44
  115. data/test/plugin/test_formatter_tsv.rb +0 -76
  116. data/test/plugin/test_in_debug_agent.rb +0 -49
  117. data/test/plugin/test_in_exec.rb +0 -261
  118. data/test/plugin/test_in_forward.rb +0 -1178
  119. data/test/plugin/test_in_gc_stat.rb +0 -62
  120. data/test/plugin/test_in_http.rb +0 -1124
  121. data/test/plugin/test_in_monitor_agent.rb +0 -922
  122. data/test/plugin/test_in_object_space.rb +0 -66
  123. data/test/plugin/test_in_sample.rb +0 -190
  124. data/test/plugin/test_in_syslog.rb +0 -505
  125. data/test/plugin/test_in_tail.rb +0 -3429
  126. data/test/plugin/test_in_tcp.rb +0 -328
  127. data/test/plugin/test_in_udp.rb +0 -296
  128. data/test/plugin/test_in_unix.rb +0 -181
  129. data/test/plugin/test_input.rb +0 -137
  130. data/test/plugin/test_metadata.rb +0 -89
  131. data/test/plugin/test_metrics.rb +0 -294
  132. data/test/plugin/test_metrics_local.rb +0 -96
  133. data/test/plugin/test_multi_output.rb +0 -204
  134. data/test/plugin/test_out_copy.rb +0 -308
  135. data/test/plugin/test_out_exec.rb +0 -312
  136. data/test/plugin/test_out_exec_filter.rb +0 -606
  137. data/test/plugin/test_out_file.rb +0 -1038
  138. data/test/plugin/test_out_forward.rb +0 -1349
  139. data/test/plugin/test_out_http.rb +0 -557
  140. data/test/plugin/test_out_null.rb +0 -105
  141. data/test/plugin/test_out_relabel.rb +0 -28
  142. data/test/plugin/test_out_roundrobin.rb +0 -146
  143. data/test/plugin/test_out_secondary_file.rb +0 -458
  144. data/test/plugin/test_out_stdout.rb +0 -205
  145. data/test/plugin/test_out_stream.rb +0 -103
  146. data/test/plugin/test_output.rb +0 -1334
  147. data/test/plugin/test_output_as_buffered.rb +0 -2024
  148. data/test/plugin/test_output_as_buffered_backup.rb +0 -363
  149. data/test/plugin/test_output_as_buffered_compress.rb +0 -179
  150. data/test/plugin/test_output_as_buffered_overflow.rb +0 -250
  151. data/test/plugin/test_output_as_buffered_retries.rb +0 -966
  152. data/test/plugin/test_output_as_buffered_secondary.rb +0 -882
  153. data/test/plugin/test_output_as_standard.rb +0 -374
  154. data/test/plugin/test_owned_by.rb +0 -34
  155. data/test/plugin/test_parser.rb +0 -399
  156. data/test/plugin/test_parser_apache.rb +0 -42
  157. data/test/plugin/test_parser_apache2.rb +0 -47
  158. data/test/plugin/test_parser_apache_error.rb +0 -45
  159. data/test/plugin/test_parser_csv.rb +0 -200
  160. data/test/plugin/test_parser_json.rb +0 -244
  161. data/test/plugin/test_parser_labeled_tsv.rb +0 -160
  162. data/test/plugin/test_parser_msgpack.rb +0 -127
  163. data/test/plugin/test_parser_multiline.rb +0 -111
  164. data/test/plugin/test_parser_nginx.rb +0 -88
  165. data/test/plugin/test_parser_none.rb +0 -52
  166. data/test/plugin/test_parser_regexp.rb +0 -284
  167. data/test/plugin/test_parser_syslog.rb +0 -650
  168. data/test/plugin/test_parser_tsv.rb +0 -122
  169. data/test/plugin/test_sd_file.rb +0 -228
  170. data/test/plugin/test_sd_srv.rb +0 -230
  171. data/test/plugin/test_storage.rb +0 -166
  172. data/test/plugin/test_storage_local.rb +0 -335
  173. data/test/plugin/test_string_util.rb +0 -26
  174. data/test/plugin_helper/data/cert/cert-key.pem +0 -27
  175. data/test/plugin_helper/data/cert/cert-with-CRLF.pem +0 -19
  176. data/test/plugin_helper/data/cert/cert-with-no-newline.pem +0 -19
  177. data/test/plugin_helper/data/cert/cert.pem +0 -19
  178. data/test/plugin_helper/data/cert/cert_chains/ca-cert-key.pem +0 -27
  179. data/test/plugin_helper/data/cert/cert_chains/ca-cert.pem +0 -20
  180. data/test/plugin_helper/data/cert/cert_chains/cert-key.pem +0 -27
  181. data/test/plugin_helper/data/cert/cert_chains/cert.pem +0 -40
  182. data/test/plugin_helper/data/cert/empty.pem +0 -0
  183. data/test/plugin_helper/data/cert/generate_cert.rb +0 -125
  184. data/test/plugin_helper/data/cert/with_ca/ca-cert-key-pass.pem +0 -30
  185. data/test/plugin_helper/data/cert/with_ca/ca-cert-key.pem +0 -27
  186. data/test/plugin_helper/data/cert/with_ca/ca-cert-pass.pem +0 -20
  187. data/test/plugin_helper/data/cert/with_ca/ca-cert.pem +0 -20
  188. data/test/plugin_helper/data/cert/with_ca/cert-key-pass.pem +0 -30
  189. data/test/plugin_helper/data/cert/with_ca/cert-key.pem +0 -27
  190. data/test/plugin_helper/data/cert/with_ca/cert-pass.pem +0 -21
  191. data/test/plugin_helper/data/cert/with_ca/cert.pem +0 -21
  192. data/test/plugin_helper/data/cert/without_ca/cert-key-pass.pem +0 -30
  193. data/test/plugin_helper/data/cert/without_ca/cert-key.pem +0 -27
  194. data/test/plugin_helper/data/cert/without_ca/cert-pass.pem +0 -20
  195. data/test/plugin_helper/data/cert/without_ca/cert.pem +0 -20
  196. data/test/plugin_helper/http_server/test_app.rb +0 -65
  197. data/test/plugin_helper/http_server/test_route.rb +0 -32
  198. data/test/plugin_helper/service_discovery/test_manager.rb +0 -93
  199. data/test/plugin_helper/service_discovery/test_round_robin_balancer.rb +0 -21
  200. data/test/plugin_helper/test_cert_option.rb +0 -25
  201. data/test/plugin_helper/test_child_process.rb +0 -862
  202. data/test/plugin_helper/test_compat_parameters.rb +0 -358
  203. data/test/plugin_helper/test_event_emitter.rb +0 -80
  204. data/test/plugin_helper/test_event_loop.rb +0 -52
  205. data/test/plugin_helper/test_extract.rb +0 -194
  206. data/test/plugin_helper/test_formatter.rb +0 -255
  207. data/test/plugin_helper/test_http_server_helper.rb +0 -372
  208. data/test/plugin_helper/test_inject.rb +0 -561
  209. data/test/plugin_helper/test_metrics.rb +0 -137
  210. data/test/plugin_helper/test_parser.rb +0 -264
  211. data/test/plugin_helper/test_record_accessor.rb +0 -238
  212. data/test/plugin_helper/test_retry_state.rb +0 -1006
  213. data/test/plugin_helper/test_server.rb +0 -1895
  214. data/test/plugin_helper/test_service_discovery.rb +0 -165
  215. data/test/plugin_helper/test_socket.rb +0 -146
  216. data/test/plugin_helper/test_storage.rb +0 -542
  217. data/test/plugin_helper/test_thread.rb +0 -164
  218. data/test/plugin_helper/test_timer.rb +0 -130
  219. data/test/scripts/exec_script.rb +0 -32
  220. data/test/scripts/fluent/plugin/formatter1/formatter_test1.rb +0 -7
  221. data/test/scripts/fluent/plugin/formatter2/formatter_test2.rb +0 -7
  222. data/test/scripts/fluent/plugin/formatter_known.rb +0 -8
  223. data/test/scripts/fluent/plugin/out_test.rb +0 -81
  224. data/test/scripts/fluent/plugin/out_test2.rb +0 -80
  225. data/test/scripts/fluent/plugin/parser_known.rb +0 -4
  226. data/test/test_capability.rb +0 -74
  227. data/test/test_clock.rb +0 -164
  228. data/test/test_config.rb +0 -369
  229. data/test/test_configdsl.rb +0 -148
  230. data/test/test_daemonizer.rb +0 -91
  231. data/test/test_engine.rb +0 -203
  232. data/test/test_event.rb +0 -531
  233. data/test/test_event_router.rb +0 -348
  234. data/test/test_event_time.rb +0 -199
  235. data/test/test_file_wrapper.rb +0 -53
  236. data/test/test_filter.rb +0 -121
  237. data/test/test_fluent_log_event_router.rb +0 -99
  238. data/test/test_formatter.rb +0 -369
  239. data/test/test_input.rb +0 -31
  240. data/test/test_log.rb +0 -1076
  241. data/test/test_match.rb +0 -148
  242. data/test/test_mixin.rb +0 -351
  243. data/test/test_msgpack_factory.rb +0 -50
  244. data/test/test_oj_options.rb +0 -55
  245. data/test/test_output.rb +0 -278
  246. data/test/test_plugin.rb +0 -251
  247. data/test/test_plugin_classes.rb +0 -370
  248. data/test/test_plugin_helper.rb +0 -81
  249. data/test/test_plugin_id.rb +0 -119
  250. data/test/test_process.rb +0 -14
  251. data/test/test_root_agent.rb +0 -951
  252. data/test/test_static_config_analysis.rb +0 -177
  253. data/test/test_supervisor.rb +0 -821
  254. data/test/test_test_drivers.rb +0 -136
  255. data/test/test_time_formatter.rb +0 -301
  256. data/test/test_time_parser.rb +0 -362
  257. data/test/test_tls.rb +0 -65
  258. data/test/test_unique_id.rb +0 -47
  259. data/test/test_variable_store.rb +0 -65
@@ -1,650 +0,0 @@
1
- require_relative '../helper'
2
- require 'fluent/test/driver/parser'
3
- require 'fluent/plugin/parser'
4
-
5
- class SyslogParserTest < ::Test::Unit::TestCase
6
- def setup
7
- Fluent::Test.setup
8
- @parser = Fluent::Test::Driver::Parser.new(Fluent::Plugin::SyslogParser)
9
- @expected = {
10
- 'host' => '192.168.0.1',
11
- 'ident' => 'fluentd',
12
- 'pid' => '11111',
13
- 'message' => '[error] Syslog test'
14
- }
15
- end
16
-
17
- data('regexp' => 'regexp', 'string' => 'string')
18
- def test_parse(param)
19
- @parser.configure({'parser_type' => param})
20
- @parser.instance.parse('Feb 28 12:00:00 192.168.0.1 fluentd[11111]: [error] Syslog test') { |time, record|
21
- assert_equal(event_time('Feb 28 12:00:00', format: '%b %d %H:%M:%S'), time)
22
- assert_equal(@expected, record)
23
- }
24
- assert_equal(Fluent::Plugin::SyslogParser::RFC3164_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
25
- assert_equal("%b %d %H:%M:%S", @parser.instance.patterns['time_format'])
26
- end
27
-
28
- data('regexp' => 'regexp', 'string' => 'string')
29
- def test_parse_with_time_format(param)
30
- @parser.configure('time_format' => '%b %d %M:%S:%H', 'parser_type' => param)
31
- @parser.instance.parse('Feb 28 00:00:12 192.168.0.1 fluentd[11111]: [error] Syslog test') { |time, record|
32
- assert_equal(event_time('Feb 28 12:00:00', format: '%b %d %H:%M:%S'), time)
33
- assert_equal(@expected, record)
34
- }
35
- assert_equal('%b %d %M:%S:%H', @parser.instance.patterns['time_format'])
36
- end
37
-
38
- data('regexp' => 'regexp', 'string' => 'string')
39
- def test_parse_with_time_format2(param)
40
- @parser.configure('time_format' => '%Y-%m-%dT%H:%M:%SZ', 'parser_type' => param)
41
- @parser.instance.parse("#{Time.now.year}-03-03T10:14:29Z 192.168.0.1 fluentd[11111]: [error] Syslog test") { |time, record|
42
- assert_equal(event_time('Mar 03 10:14:29', format: '%b %d %H:%M:%S'), time)
43
- assert_equal(@expected, record)
44
- }
45
- assert_equal('%Y-%m-%dT%H:%M:%SZ', @parser.instance.patterns['time_format'])
46
- end
47
-
48
- def test_parse_with_time_format_rfc5424
49
- @parser.configure('time_format' => '%Y-%m-%dT%H:%M:%SZ', 'message_format' => 'rfc5424')
50
- @parser.instance.parse("#{Time.now.year}-03-03T10:14:29Z 192.168.0.1 fluentd 11111 - - [error] Syslog test") { |time, record|
51
- assert_equal(event_time('Mar 03 10:14:29', format: '%b %d %H:%M:%S'), time)
52
- assert_equal(@expected.merge('host' => '192.168.0.1', 'msgid' => '-', 'extradata' => '-'), record)
53
- }
54
- assert_equal('%Y-%m-%dT%H:%M:%SZ', @parser.instance.patterns['time_format'])
55
- end
56
-
57
- data('regexp' => 'regexp', 'string' => 'string')
58
- def test_parse_with_subsecond_time(param)
59
- @parser.configure('time_format' => '%b %d %H:%M:%S.%N', 'parser_type' => param)
60
- @parser.instance.parse('Feb 28 12:00:00.456 192.168.0.1 fluentd[11111]: [error] Syslog test') { |time, record|
61
- assert_equal(event_time('Feb 28 12:00:00.456', format: '%b %d %H:%M:%S.%N'), time)
62
- assert_equal(@expected, record)
63
- }
64
- end
65
-
66
- data('regexp' => 'regexp', 'string' => 'string')
67
- def test_parse_with_priority(param)
68
- @parser.configure('with_priority' => true, 'parser_type' => param)
69
- @parser.instance.parse('<6>Feb 28 12:00:00 192.168.0.1 fluentd[11111]: [error] Syslog test') { |time, record|
70
- assert_equal(event_time('Feb 28 12:00:00', format: '%b %d %H:%M:%S'), time)
71
- assert_equal(@expected.merge('pri' => 6), record)
72
- }
73
- assert_equal(Fluent::Plugin::SyslogParser::RFC3164_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
74
- assert_equal("%b %d %H:%M:%S", @parser.instance.patterns['time_format'])
75
- end
76
-
77
- data('regexp' => 'regexp', 'string' => 'string')
78
- def test_parse_rfc5452_with_priority(param)
79
- @parser.configure('with_priority' => true, 'parser_type' => param, 'message_format' => 'rfc5424')
80
- @parser.instance.parse('<30>1 2020-03-31T20:32:54Z myhostname 02abaf0687f5 10339 02abaf0687f5 - method=POST db=0.00') do |time, record|
81
- assert_equal(event_time('2020-03-31T20:32:54Z', format: '%Y-%m-%dT%H:%M:%S%z'), time)
82
- expected = { 'extradata' => '-', 'host' => 'myhostname', 'ident' => '02abaf0687f5', 'message' => 'method=POST db=0.00', 'msgid' => '02abaf0687f5', 'pid' => '10339', 'pri' => 30 }
83
- assert_equal(expected, record)
84
- end
85
- end
86
-
87
- data('regexp' => 'regexp', 'string' => 'string')
88
- def test_parse_with_empty_priority(param)
89
- @parser.configure('with_priority' => true, 'parser_type' => param)
90
- @parser.instance.parse('<>Feb 28 12:00:00 192.168.0.1 fluentd[11111]: [error] Syslog test') { |time, record|
91
- assert_nil time
92
- assert_nil record
93
- }
94
- end
95
-
96
- data('regexp' => 'regexp', 'string' => 'string')
97
- def test_parse_without_colon(param)
98
- @parser.configure({'parser_type' => param})
99
- @parser.instance.parse('Feb 28 12:00:00 192.168.0.1 fluentd[11111] [error] Syslog test') { |time, record|
100
- assert_equal(event_time('Feb 28 12:00:00', format: '%b %d %H:%M:%S'), time)
101
- assert_equal(@expected, record)
102
- }
103
- assert_equal(Fluent::Plugin::SyslogParser::RFC3164_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
104
- assert_equal("%b %d %H:%M:%S", @parser.instance.patterns['time_format'])
105
- end
106
-
107
- data('regexp' => 'regexp', 'string' => 'string')
108
- def test_parse_with_keep_time_key(param)
109
- @parser.configure(
110
- 'time_format' => '%b %d %M:%S:%H',
111
- 'keep_time_key'=>'true',
112
- 'parser_type' => param
113
- )
114
- text = 'Feb 28 00:00:12 192.168.0.1 fluentd[11111]: [error] Syslog test'
115
- @parser.instance.parse(text) do |time, record|
116
- assert_equal "Feb 28 00:00:12", record['time']
117
- end
118
- end
119
-
120
- data('regexp' => 'regexp', 'string' => 'string')
121
- def test_parse_various_characters_for_tag(param)
122
- ident = '~!@#$%^&*()_+=-`]{};"\'/?\\,.<>'
123
- @parser.configure({'parser_type' => param})
124
- @parser.instance.parse("Feb 28 12:00:00 192.168.0.1 #{ident}[11111]: [error] Syslog test") { |time, record|
125
- assert_equal(event_time('Feb 28 12:00:00', format: '%b %d %H:%M:%S'), time)
126
- assert_equal(@expected.merge('ident' => ident), record)
127
- }
128
- end
129
-
130
- data('regexp' => 'regexp', 'string' => 'string')
131
- def test_parse_various_characters_for_tag_with_priority(param)
132
- ident = '~!@#$%^&*()_+=-`]{};"\'/?\\,.<>'
133
- @parser.configure('with_priority' => true, 'parser_type' => param)
134
- @parser.instance.parse("<6>Feb 28 12:00:00 192.168.0.1 #{ident}[11111]: [error] Syslog test") { |time, record|
135
- assert_equal(event_time('Feb 28 12:00:00', format: '%b %d %H:%M:%S'), time)
136
- assert_equal(@expected.merge('pri' => 6, 'ident' => ident), record)
137
- }
138
- end
139
-
140
- sub_test_case 'Check the difference of regexp and string parser' do
141
- # examples from rfc3164
142
- data('regexp' => 'regexp', 'string' => 'string')
143
- test 'wrong result with no ident message by default' do |param|
144
- @parser.configure('parser_type' => param)
145
- @parser.instance.parse('Feb 5 17:32:18 10.0.0.99 Use the BFG!') { |time, record|
146
- assert_equal({'host' => '10.0.0.99', 'ident' => 'Use', 'message' => 'the BFG!'}, record)
147
- }
148
- end
149
-
150
- test "proper result with no ident message by 'support_colonless_ident false'" do
151
- @parser.configure('parser_type' => 'string', 'support_colonless_ident' => false)
152
- @parser.instance.parse('Feb 5 17:32:18 10.0.0.99 Use the BFG!') { |time, record|
153
- assert_equal({'host' => '10.0.0.99', 'message' => 'Use the BFG!'}, record)
154
- }
155
- end
156
-
157
- test "string parsers can't parse broken syslog message and generate wrong record" do
158
- @parser.configure('parser_type' => 'string')
159
- @parser.instance.parse("1990 Oct 22 10:52:01 TZ-6 scapegoat.dmz.example.org 10.1.2.32 sched[0]: That's All Folks!") { |time, record|
160
- expected = {'host' => 'scapegoat.dmz.example.org', 'ident' => 'sched', 'pid' => '0', 'message' => "That's All Folks!"}
161
- assert_not_equal(expected, record)
162
- }
163
- end
164
-
165
- test "regexp parsers can't parse broken syslog message and raises an error" do
166
- @parser.configure('parser_type' => 'regexp')
167
- assert_raise(Fluent::TimeParser::TimeParseError) {
168
- @parser.instance.parse("1990 Oct 22 10:52:01 TZ-6 scapegoat.dmz.example.org 10.1.2.32 sched[0]: That's All Folks!") { |time, record| }
169
- }
170
- end
171
-
172
- data('regexp' => 'regexp', 'string' => 'string')
173
- test "':' included message breaks regexp parser" do |param|
174
- @parser.configure('parser_type' => param)
175
- @parser.instance.parse('Aug 10 12:00:00 127.0.0.1 test foo:bar') { |time, record|
176
- expected = {'host' => '127.0.0.1', 'ident' => 'test', 'message' => 'foo:bar'}
177
- if param == 'string'
178
- assert_equal(expected, record)
179
- else
180
- assert_not_equal(expected, record)
181
- end
182
- }
183
- end
184
-
185
- data('regexp' => 'regexp', 'string' => 'string')
186
- test "Only no whitespace content in MSG causes different result" do |param|
187
- @parser.configure('parser_type' => param)
188
- @parser.instance.parse('Aug 10 12:00:00 127.0.0.1 value1,value2,value3,value4') { |time, record|
189
- # 'message' is correct but regexp set it as 'ident'
190
- if param == 'string'
191
- expected = {'host' => '127.0.0.1', 'message' => 'value1,value2,value3,value4'}
192
- assert_equal(expected, record)
193
- else
194
- expected = {'host' => '127.0.0.1', 'ident' => 'value1,value2,value3,value4', 'message' => ''}
195
- assert_equal(expected, record)
196
- end
197
- }
198
- end
199
- end
200
-
201
- class TestRFC5424Regexp < self
202
- data('regexp' => 'regexp', 'string' => 'string')
203
- def test_parse_with_rfc5424_message(param)
204
- @parser.configure(
205
- 'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
206
- 'message_format' => 'rfc5424',
207
- 'with_priority' => true,
208
- 'parser_type' => param
209
- )
210
- text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - - Hi, from Fluentd!'
211
- @parser.instance.parse(text) do |time, record|
212
- assert_equal(event_time("2017-02-06T13:14:15.003Z", format: '%Y-%m-%dT%H:%M:%S.%L%z'), time)
213
- assert_equal "-", record["pid"]
214
- assert_equal "-", record["msgid"]
215
- assert_equal "-", record["extradata"]
216
- assert_equal "Hi, from Fluentd!", record["message"]
217
- end
218
- assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
219
- end
220
-
221
- data('regexp' => 'regexp', 'string' => 'string')
222
- def test_parse_with_rfc5424_message_trailing_eol(param)
223
- @parser.configure(
224
- 'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
225
- 'message_format' => 'rfc5424',
226
- 'with_priority' => true,
227
- 'parser_type' => param
228
- )
229
- text = "<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - - Hi, from Fluentd!\n"
230
- @parser.instance.parse(text) do |time, record|
231
- assert_equal(event_time("2017-02-06T13:14:15.003Z", format: '%Y-%m-%dT%H:%M:%S.%L%z'), time)
232
- assert_equal "-", record["pid"]
233
- assert_equal "-", record["msgid"]
234
- assert_equal "-", record["extradata"]
235
- assert_equal "Hi, from Fluentd!", record["message"]
236
- end
237
- assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
238
- end
239
-
240
- data('regexp' => 'regexp', 'string' => 'string')
241
- def test_parse_with_rfc5424_multiline_message(param)
242
- @parser.configure(
243
- 'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
244
- 'message_format' => 'rfc5424',
245
- 'with_priority' => true,
246
- 'parser_type' => param
247
- )
248
- text = "<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - - Hi,\nfrom\nFluentd!"
249
- @parser.instance.parse(text) do |time, record|
250
- assert_equal(event_time("2017-02-06T13:14:15.003Z", format: '%Y-%m-%dT%H:%M:%S.%L%z'), time)
251
- assert_equal "-", record["pid"]
252
- assert_equal "-", record["msgid"]
253
- assert_equal "-", record["extradata"]
254
- assert_equal "Hi,\nfrom\nFluentd!", record["message"]
255
- end
256
- assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
257
- end
258
-
259
- data('regexp' => 'regexp', 'string' => 'string')
260
- def test_parse_with_rfc5424_message_and_without_priority(param)
261
- @parser.configure(
262
- 'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
263
- 'message_format' => 'rfc5424',
264
- 'parser_type' => param
265
- )
266
- text = '2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - - Hi, from Fluentd!'
267
- @parser.instance.parse(text) do |time, record|
268
- assert_equal(event_time("2017-02-06T13:14:15.003Z", format: '%Y-%m-%dT%H:%M:%S.%L%z'), time)
269
- assert_equal "-", record["pid"]
270
- assert_equal "-", record["msgid"]
271
- assert_equal "-", record["extradata"]
272
- assert_equal "Hi, from Fluentd!", record["message"]
273
- end
274
- assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
275
- end
276
-
277
- data('regexp' => 'regexp', 'string' => 'string')
278
- def test_parse_with_rfc5424_empty_message_and_without_priority(param)
279
- @parser.configure(
280
- 'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
281
- 'message_format' => 'rfc5424',
282
- 'parser_type' => param
283
- )
284
- text = '2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - -'
285
- @parser.instance.parse(text) do |time, record|
286
- assert_equal(event_time("2017-02-06T13:14:15.003Z", format: '%Y-%m-%dT%H:%M:%S.%L%z'), time)
287
- assert_equal "-", record["pid"]
288
- assert_equal "-", record["msgid"]
289
- assert_equal "-", record["extradata"]
290
- assert_nil record["message"]
291
- end
292
- assert_equal(Fluent::Plugin::SyslogParser::RFC5424_WITHOUT_TIME_AND_PRI_REGEXP, @parser.instance.patterns['format'])
293
- end
294
-
295
- data('regexp' => 'regexp', 'string' => 'string')
296
- def test_parse_with_rfc5424_message_without_time_format(param)
297
- @parser.configure(
298
- 'message_format' => 'rfc5424',
299
- 'with_priority' => true,
300
- 'parser_type' => param
301
- )
302
- text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - - Hi, from Fluentd!'
303
- @parser.instance.parse(text) do |time, record|
304
- assert_equal(event_time("2017-02-06T13:14:15.003Z", format: '%Y-%m-%dT%H:%M:%S.%L%z'), time)
305
- assert_equal "-", record["pid"]
306
- assert_equal "-", record["msgid"]
307
- assert_equal "-", record["extradata"]
308
- assert_equal "Hi, from Fluentd!", record["message"]
309
- end
310
- end
311
-
312
- data('regexp' => 'regexp', 'string' => 'string')
313
- def test_parse_with_rfc5424_message_with_priority_and_pid(param)
314
- @parser.configure(
315
- 'message_format' => 'rfc5424',
316
- 'with_priority' => true,
317
- 'parser_type' => param
318
- )
319
- text = '<28>1 2018-09-26T15:54:26.620412+09:00 machine minissdpd 1298 - - peer 192.168.0.5:50123 is not from a LAN'
320
- @parser.instance.parse(text) do |time, record|
321
- assert_equal(event_time("2018-09-26T15:54:26.620412+0900", format: '%Y-%m-%dT%H:%M:%S.%L%z'), time)
322
- assert_equal "1298", record["pid"]
323
- assert_equal "-", record["msgid"]
324
- assert_equal "-", record["extradata"]
325
- assert_equal " peer 192.168.0.5:50123 is not from a LAN", record["message"]
326
- end
327
- end
328
-
329
- data('regexp' => 'regexp', 'string' => 'string')
330
- def test_parse_with_rfc5424_structured_message(param)
331
- @parser.configure(
332
- 'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
333
- 'message_format' => 'rfc5424',
334
- 'with_priority' => true,
335
- 'parser_type' => param
336
- )
337
- text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd 11111 ID24224 [exampleSDID@20224 iut="3" eventSource="Application" eventID="11211"] [Hi] from Fluentd!'
338
- @parser.instance.parse(text) do |time, record|
339
- assert_equal(event_time("2017-02-06T13:14:15.003Z", format: '%Y-%m-%dT%H:%M:%S.%L%z'), time)
340
- assert_equal "11111", record["pid"]
341
- assert_equal "ID24224", record["msgid"]
342
- assert_equal "[exampleSDID@20224 iut=\"3\" eventSource=\"Application\" eventID=\"11211\"]",
343
- record["extradata"]
344
- assert_equal "[Hi] from Fluentd!", record["message"]
345
- end
346
- end
347
-
348
- data('regexp' => 'regexp', 'string' => 'string')
349
- def test_parse_with_rfc5424_multiple_structured_message(param)
350
- @parser.configure(
351
- 'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
352
- 'message_format' => 'rfc5424',
353
- 'with_priority' => true,
354
- 'parser_type' => param
355
- )
356
- text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd 11111 ID24224 [exampleSDID@20224 iut="3" eventSource="Application" eventID="11211"][exampleSDID@20224 class="high"] Hi, from Fluentd!'
357
- @parser.instance.parse(text) do |time, record|
358
- assert_equal(event_time("2017-02-06T13:14:15.003Z", format: '%Y-%m-%dT%H:%M:%S.%L%z'), time)
359
- assert_equal "11111", record["pid"]
360
- assert_equal "ID24224", record["msgid"]
361
- assert_equal "[exampleSDID@20224 iut=\"3\" eventSource=\"Application\" eventID=\"11211\"][exampleSDID@20224 class=\"high\"]",
362
- record["extradata"]
363
- assert_equal "Hi, from Fluentd!", record["message"]
364
- end
365
- end
366
-
367
- data('regexp' => 'regexp', 'string' => 'string')
368
- def test_parse_with_rfc5424_message_includes_right_bracket(param)
369
- @parser.configure(
370
- 'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
371
- 'message_format' => 'rfc5424',
372
- 'with_priority' => true,
373
- 'parser_type' => param
374
- )
375
- text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd 11111 ID24224 [exampleSDID@20224 iut="3" eventSource="Application" eventID="11211"] [Hi] from Fluentd]!'
376
- @parser.instance.parse(text) do |time, record|
377
- assert_equal(event_time("2017-02-06T13:14:15.003Z", format: '%Y-%m-%dT%H:%M:%S.%L%z'), time)
378
- assert_equal "11111", record["pid"]
379
- assert_equal "ID24224", record["msgid"]
380
- assert_equal "[exampleSDID@20224 iut=\"3\" eventSource=\"Application\" eventID=\"11211\"]",
381
- record["extradata"]
382
- assert_equal "[Hi] from Fluentd]!", record["message"]
383
- end
384
- end
385
-
386
- data('regexp' => 'regexp', 'string' => 'string')
387
- def test_parse_with_rfc5424_empty_message(param)
388
- @parser.configure(
389
- 'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
390
- 'message_format' => 'rfc5424',
391
- 'with_priority' => true,
392
- 'parser_type' => param
393
- )
394
- text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd 11111 ID24224 [exampleSDID@20224 iut="3" eventSource="Application" eventID="11211"]'
395
- @parser.instance.parse(text) do |time, record|
396
- assert_equal(event_time("2017-02-06T13:14:15.003Z", format: '%Y-%m-%dT%H:%M:%S.%L%z'), time)
397
- assert_equal "11111", record["pid"]
398
- assert_equal "ID24224", record["msgid"]
399
- assert_equal "[exampleSDID@20224 iut=\"3\" eventSource=\"Application\" eventID=\"11211\"]",
400
- record["extradata"]
401
- assert_nil record["message"]
402
- end
403
- end
404
-
405
- data('regexp' => 'regexp', 'string' => 'string')
406
- def test_parse_with_rfc5424_space_empty_message(param)
407
- @parser.configure(
408
- 'message_format' => 'rfc5424',
409
- 'with_priority' => true,
410
- 'parser_type' => param
411
- )
412
- text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd 11111 ID24224 [exampleSDID@20224 iut="3" eventSource="Application" eventID="11211"] '
413
- @parser.instance.parse(text) do |time, record|
414
- if param == 'string'
415
- assert_equal(event_time("2017-02-06T13:14:15.003Z", format: '%Y-%m-%dT%H:%M:%S.%L%z'), time)
416
- assert_equal "11111", record["pid"]
417
- assert_equal "ID24224", record["msgid"]
418
- assert_equal "[exampleSDID@20224 iut=\"3\" eventSource=\"Application\" eventID=\"11211\"]",
419
- record["extradata"]
420
- assert_equal '', record["message"]
421
- else
422
- assert_nil time
423
- assert_nil record
424
- end
425
- end
426
- end
427
-
428
- data('regexp' => 'regexp', 'string' => 'string')
429
- def test_parse_with_rfc5424_message_without_subseconds(param)
430
- @parser.configure(
431
- 'message_format' => 'rfc5424',
432
- 'with_priority' => true,
433
- 'parser_type' => param
434
- )
435
- text = '<16>1 2017-02-06T13:14:15Z 192.168.0.1 fluentd - - - Hi, from Fluentd!'
436
- @parser.instance.parse(text) do |time, record|
437
- assert_equal(event_time("2017-02-06T13:14:15Z", format: '%Y-%m-%dT%H:%M:%S%z'), time)
438
- assert_equal "-", record["pid"]
439
- assert_equal "-", record["msgid"]
440
- assert_equal "-", record["extradata"]
441
- assert_equal "Hi, from Fluentd!", record["message"]
442
- end
443
- end
444
-
445
- data('regexp' => 'regexp', 'string' => 'string')
446
- def test_parse_with_rfc5424_message_both_timestamp(param)
447
- @parser.configure(
448
- 'message_format' => 'rfc5424',
449
- 'with_priority' => true,
450
- 'parser_type' => param
451
- )
452
- text = '<16>1 2017-02-06T13:14:15Z 192.168.0.1 fluentd - - - Hi, from Fluentd!'
453
- @parser.instance.parse(text) do |time, record|
454
- assert_equal(event_time("2017-02-06T13:14:15Z", format: '%Y-%m-%dT%H:%M:%S%z'), time)
455
- assert_equal "-", record["pid"]
456
- assert_equal "-", record["msgid"]
457
- assert_equal "-", record["extradata"]
458
- assert_equal "Hi, from Fluentd!", record["message"]
459
- end
460
- text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - - Hi, from Fluentd with subseconds!'
461
- @parser.instance.parse(text) do |time, record|
462
- assert_equal(event_time("2017-02-06T13:14:15.003Z", format: '%Y-%m-%dT%H:%M:%S.%L%z'), time)
463
- assert_equal "-", record["pid"]
464
- assert_equal "-", record["msgid"]
465
- assert_equal "-", record["extradata"]
466
- assert_equal "Hi, from Fluentd with subseconds!", record["message"]
467
- end
468
- end
469
- end
470
-
471
- class TestAutoRegexp < self
472
- data('regexp' => 'regexp', 'string' => 'string')
473
- def test_auto_with_legacy_syslog_message(param)
474
- @parser.configure(
475
- 'time_format' => '%b %d %M:%S:%H',
476
- 'message_format' => 'auto',
477
- 'parser_type' => param
478
- )
479
- text = 'Feb 28 00:00:12 192.168.0.1 fluentd[11111]: [error] Syslog test'
480
- @parser.instance.parse(text) do |time, record|
481
- assert_equal(event_time("Feb 28 00:00:12", format: '%b %d %M:%S:%H'), time)
482
- assert_equal(@expected, record)
483
- end
484
- end
485
-
486
- data('regexp' => 'regexp', 'string' => 'string')
487
- def test_auto_with_legacy_syslog_priority_message(param)
488
- @parser.configure(
489
- 'time_format' => '%b %d %M:%S:%H',
490
- 'with_priority' => true,
491
- 'message_format' => 'auto',
492
- 'parser_type' => param
493
- )
494
- text = '<6>Feb 28 12:00:00 192.168.0.1 fluentd[11111]: [error] Syslog test'
495
- @parser.instance.parse(text) do |time, record|
496
- assert_equal(event_time("Feb 28 12:00:00", format: '%b %d %M:%S:%H'), time)
497
- assert_equal(@expected.merge('pri' => 6), record)
498
- end
499
- end
500
-
501
- data('regexp' => 'regexp', 'string' => 'string')
502
- def test_parse_with_rfc5424_message(param)
503
- @parser.configure(
504
- 'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
505
- 'message_format' => 'auto',
506
- 'with_priority' => true,
507
- 'parser_type' => param
508
- )
509
- text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - - Hi, from Fluentd!'
510
- @parser.instance.parse(text) do |time, record|
511
- assert_equal(event_time("2017-02-06T13:14:15.003Z", format: '%Y-%m-%dT%H:%M:%S.%L%z'), time)
512
- assert_equal "-", record["pid"]
513
- assert_equal "-", record["msgid"]
514
- assert_equal "-", record["extradata"]
515
- assert_equal 16, record["pri"]
516
- assert_equal "Hi, from Fluentd!", record["message"]
517
- end
518
- end
519
-
520
- data('regexp' => 'regexp', 'string' => 'string')
521
- def test_parse_with_rfc5424_structured_message(param)
522
- @parser.configure(
523
- 'time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
524
- 'message_format' => 'auto',
525
- 'with_priority' => true,
526
- 'parser_type' => param
527
- )
528
- text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd 11111 ID24224 [exampleSDID@20224 iut="3" eventSource="Application" eventID="11211"] Hi, from Fluentd!'
529
- @parser.instance.parse(text) do |time, record|
530
- assert_equal(event_time("2017-02-06T13:14:15.003Z", format: '%Y-%m-%dT%H:%M:%S.%L%z'), time)
531
- assert_equal "11111", record["pid"]
532
- assert_equal "ID24224", record["msgid"]
533
- assert_equal "[exampleSDID@20224 iut=\"3\" eventSource=\"Application\" eventID=\"11211\"]",
534
- record["extradata"]
535
- assert_equal "Hi, from Fluentd!", record["message"]
536
- end
537
- end
538
-
539
- data('regexp' => 'regexp', 'string' => 'string')
540
- def test_parse_with_both_message_type(param)
541
- @parser.configure(
542
- 'time_format' => '%b %d %M:%S:%H',
543
- 'rfc5424_time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
544
- 'message_format' => 'auto',
545
- 'with_priority' => true,
546
- 'parser_type' => param
547
- )
548
- text = '<1>Feb 28 12:00:00 192.168.0.1 fluentd[11111]: [error] Syslog test'
549
- @parser.instance.parse(text) do |time, record|
550
- assert_equal(event_time("Feb 28 12:00:00", format: '%b %d %M:%S:%H'), time)
551
- assert_equal(@expected.merge('pri' => 1), record)
552
- end
553
-
554
- text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd 11111 ID24224 [exampleSDID@20224 iut="3" eventSource="Application" eventID="11211"] Hi, from Fluentd!'
555
- @parser.instance.parse(text) do |time, record|
556
- assert_equal(event_time("2017-02-06T13:14:15.003Z", format: '%Y-%m-%dT%H:%M:%S.%L%z'), time)
557
- assert_equal "11111", record["pid"]
558
- assert_equal "ID24224", record["msgid"]
559
- assert_equal "[exampleSDID@20224 iut=\"3\" eventSource=\"Application\" eventID=\"11211\"]",
560
- record["extradata"]
561
- assert_equal "Hi, from Fluentd!", record["message"]
562
- end
563
-
564
- text = '<1>Feb 28 12:00:02 192.168.0.1 fluentd[11111]: [error] Syslog test 2>1'
565
- @parser.instance.parse(text) do |time, record|
566
- assert_equal(event_time("Feb 28 12:00:02", format: '%b %d %M:%S:%H'), time)
567
- assert_equal(@expected.merge('pri' => 1, 'message'=> '[error] Syslog test 2>1'), record)
568
- end
569
-
570
- text = '<1>Feb 28 12:00:02 192.168.0.1 fluentd[11111]: [error] Syslog test'
571
- @parser.instance.parse(text) do |time, record|
572
- assert_equal(event_time("Feb 28 12:00:02", format: '%b %d %M:%S:%H'), time)
573
- assert_equal(@expected.merge('pri' => 1), record)
574
- end
575
-
576
- text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - - Hi, from Fluentd!'
577
- @parser.instance.parse(text) do |time, record|
578
- assert_equal(event_time("2017-02-06T13:14:15.003Z", format: '%Y-%m-%dT%H:%M:%S.%L%z'), time)
579
- assert_equal "-", record["pid"]
580
- assert_equal "-", record["msgid"]
581
- assert_equal "-", record["extradata"]
582
- assert_equal "Hi, from Fluentd!", record["message"]
583
- end
584
- end
585
-
586
- data('regexp' => 'regexp', 'string' => 'string')
587
- def test_parse_with_both_message_type_and_priority(param)
588
- @parser.configure(
589
- 'time_format' => '%b %d %M:%S:%H',
590
- 'rfc5424_time_format' => '%Y-%m-%dT%H:%M:%S.%L%z',
591
- 'with_priority' => true,
592
- 'message_format' => 'auto',
593
- 'parser_type' => param
594
- )
595
- text = '<6>Feb 28 12:00:00 192.168.0.1 fluentd[11111]: [error] Syslog test'
596
- @parser.instance.parse(text) do |time, record|
597
- assert_equal(event_time("Feb 28 12:00:00", format: '%b %d %M:%S:%H'), time)
598
- assert_equal(@expected.merge('pri' => 6), record)
599
- end
600
-
601
- text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd 11111 ID24224 [exampleSDID@20224 iut="3" eventSource="Application" eventID="11211"] Hi, from Fluentd!'
602
- @parser.instance.parse(text) do |time, record|
603
- assert_equal(event_time("2017-02-06T13:14:15.003Z", format: '%Y-%m-%dT%H:%M:%S.%L%z'), time)
604
- assert_equal "11111", record["pid"]
605
- assert_equal "ID24224", record["msgid"]
606
- assert_equal "[exampleSDID@20224 iut=\"3\" eventSource=\"Application\" eventID=\"11211\"]",
607
- record["extradata"]
608
- assert_equal "Hi, from Fluentd!", record["message"]
609
- end
610
-
611
- text = '<16>Feb 28 12:00:02 192.168.0.1 fluentd[11111]: [error] Syslog test'
612
- @parser.instance.parse(text) do |time, record|
613
- assert_equal(event_time("Feb 28 12:00:02", format: '%b %d %M:%S:%H'), time)
614
- assert_equal(@expected.merge('pri' => 16), record)
615
- end
616
-
617
- text = '<16>1 2017-02-06T13:14:15.003Z 192.168.0.1 fluentd - - - Hi, from Fluentd!'
618
- @parser.instance.parse(text) do |time, record|
619
- assert_equal(event_time("2017-02-06T13:14:15.003Z", format: '%Y-%m-%dT%H:%M:%S.%L%z'), time)
620
- assert_equal "-", record["pid"]
621
- assert_equal "-", record["msgid"]
622
- assert_equal "-", record["extradata"]
623
- assert_equal "Hi, from Fluentd!", record["message"]
624
- end
625
-
626
- text = '<16>1 2017-02-06T13:14:15Z 192.168.0.1 fluentd - - - Hi, from Fluentd without subseconds!'
627
- @parser.instance.parse(text) do |time, record|
628
- assert_equal(event_time("2017-02-06T13:14:15Z", format: '%Y-%m-%dT%H:%M:%S%z'), time)
629
- assert_equal "-", record["pid"]
630
- assert_equal "-", record["msgid"]
631
- assert_equal "-", record["extradata"]
632
- assert_equal "Hi, from Fluentd without subseconds!", record["message"]
633
- end
634
- end
635
- end
636
-
637
- # "parser_type" config shouldn't hide Fluent::Plugin::Parser#plugin_type
638
- # https://github.com/fluent/fluentd/issues/3296
639
- data('regexp' => :regexp, 'fast' => :string)
640
- def test_parser_type_method(engine)
641
- @parser.configure({'parser_type' => engine.to_s})
642
- assert_equal(:text_per_line, @parser.instance.parser_type)
643
- end
644
-
645
- data('regexp' => :regexp, 'string' => :string)
646
- def test_parser_engine(engine)
647
- @parser.configure({'parser_engine' => engine.to_s})
648
- assert_equal(engine, @parser.instance.parser_engine)
649
- end
650
- end