fluentd-hubspot 0.14.14.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.github/ISSUE_TEMPLATE.md +6 -0
- data/.gitignore +28 -0
- data/.travis.yml +51 -0
- data/AUTHORS +2 -0
- data/CONTRIBUTING.md +42 -0
- data/COPYING +14 -0
- data/ChangeLog +593 -0
- data/Gemfile +9 -0
- data/README.md +76 -0
- data/Rakefile +74 -0
- data/Vagrantfile +17 -0
- data/appveyor.yml +43 -0
- data/bin/fluent-binlog-reader +7 -0
- data/bin/fluent-debug +5 -0
- data/bin/fluent-plugin-config-format +5 -0
- data/bin/fluent-plugin-generate +5 -0
- data/code-of-conduct.md +3 -0
- data/example/copy_roundrobin.conf +39 -0
- data/example/filter_stdout.conf +22 -0
- data/example/in_dummy_blocks.conf +17 -0
- data/example/in_dummy_with_compression.conf +23 -0
- data/example/in_forward.conf +14 -0
- data/example/in_forward_client.conf +37 -0
- data/example/in_forward_shared_key.conf +15 -0
- data/example/in_forward_tls.conf +14 -0
- data/example/in_forward_users.conf +24 -0
- data/example/in_forward_workers.conf +21 -0
- data/example/in_http.conf +14 -0
- data/example/in_out_forward.conf +17 -0
- data/example/in_syslog.conf +15 -0
- data/example/in_tail.conf +14 -0
- data/example/in_tcp.conf +13 -0
- data/example/in_udp.conf +13 -0
- data/example/logevents.conf +25 -0
- data/example/multi_filters.conf +61 -0
- data/example/out_copy.conf +20 -0
- data/example/out_exec_filter.conf +42 -0
- data/example/out_file.conf +13 -0
- data/example/out_forward.conf +35 -0
- data/example/out_forward_buf_file.conf +23 -0
- data/example/out_forward_client.conf +109 -0
- data/example/out_forward_heartbeat_none.conf +16 -0
- data/example/out_forward_shared_key.conf +36 -0
- data/example/out_forward_tls.conf +18 -0
- data/example/out_forward_users.conf +65 -0
- data/example/out_null.conf +36 -0
- data/example/secondary_file.conf +41 -0
- data/example/suppress_config_dump.conf +7 -0
- data/example/v0_12_filter.conf +78 -0
- data/example/v1_literal_example.conf +36 -0
- data/fluent.conf +139 -0
- data/fluentd.gemspec +51 -0
- data/lib/fluent/agent.rb +163 -0
- data/lib/fluent/clock.rb +62 -0
- data/lib/fluent/command/binlog_reader.rb +234 -0
- data/lib/fluent/command/bundler_injection.rb +45 -0
- data/lib/fluent/command/cat.rb +330 -0
- data/lib/fluent/command/debug.rb +102 -0
- data/lib/fluent/command/fluentd.rb +301 -0
- data/lib/fluent/command/plugin_config_formatter.rb +258 -0
- data/lib/fluent/command/plugin_generator.rb +301 -0
- data/lib/fluent/compat/call_super_mixin.rb +67 -0
- data/lib/fluent/compat/detach_process_mixin.rb +25 -0
- data/lib/fluent/compat/exec_util.rb +129 -0
- data/lib/fluent/compat/file_util.rb +54 -0
- data/lib/fluent/compat/filter.rb +68 -0
- data/lib/fluent/compat/formatter.rb +111 -0
- data/lib/fluent/compat/formatter_utils.rb +85 -0
- data/lib/fluent/compat/handle_tag_and_time_mixin.rb +62 -0
- data/lib/fluent/compat/handle_tag_name_mixin.rb +53 -0
- data/lib/fluent/compat/input.rb +59 -0
- data/lib/fluent/compat/output.rb +728 -0
- data/lib/fluent/compat/output_chain.rb +60 -0
- data/lib/fluent/compat/parser.rb +310 -0
- data/lib/fluent/compat/parser_utils.rb +40 -0
- data/lib/fluent/compat/propagate_default.rb +62 -0
- data/lib/fluent/compat/record_filter_mixin.rb +34 -0
- data/lib/fluent/compat/set_tag_key_mixin.rb +50 -0
- data/lib/fluent/compat/set_time_key_mixin.rb +69 -0
- data/lib/fluent/compat/socket_util.rb +165 -0
- data/lib/fluent/compat/string_util.rb +34 -0
- data/lib/fluent/compat/structured_format_mixin.rb +26 -0
- data/lib/fluent/compat/type_converter.rb +90 -0
- data/lib/fluent/config.rb +56 -0
- data/lib/fluent/config/basic_parser.rb +123 -0
- data/lib/fluent/config/configure_proxy.rb +418 -0
- data/lib/fluent/config/dsl.rb +149 -0
- data/lib/fluent/config/element.rb +218 -0
- data/lib/fluent/config/error.rb +26 -0
- data/lib/fluent/config/literal_parser.rb +251 -0
- data/lib/fluent/config/parser.rb +107 -0
- data/lib/fluent/config/section.rb +223 -0
- data/lib/fluent/config/types.rb +136 -0
- data/lib/fluent/config/v1_parser.rb +190 -0
- data/lib/fluent/configurable.rb +200 -0
- data/lib/fluent/daemon.rb +15 -0
- data/lib/fluent/engine.rb +266 -0
- data/lib/fluent/env.rb +28 -0
- data/lib/fluent/error.rb +30 -0
- data/lib/fluent/event.rb +334 -0
- data/lib/fluent/event_router.rb +269 -0
- data/lib/fluent/filter.rb +21 -0
- data/lib/fluent/formatter.rb +23 -0
- data/lib/fluent/input.rb +21 -0
- data/lib/fluent/label.rb +46 -0
- data/lib/fluent/load.rb +35 -0
- data/lib/fluent/log.rb +546 -0
- data/lib/fluent/match.rb +178 -0
- data/lib/fluent/mixin.rb +31 -0
- data/lib/fluent/msgpack_factory.rb +62 -0
- data/lib/fluent/output.rb +29 -0
- data/lib/fluent/output_chain.rb +23 -0
- data/lib/fluent/parser.rb +23 -0
- data/lib/fluent/plugin.rb +183 -0
- data/lib/fluent/plugin/bare_output.rb +63 -0
- data/lib/fluent/plugin/base.rb +165 -0
- data/lib/fluent/plugin/buf_file.rb +184 -0
- data/lib/fluent/plugin/buf_memory.rb +34 -0
- data/lib/fluent/plugin/buffer.rb +617 -0
- data/lib/fluent/plugin/buffer/chunk.rb +221 -0
- data/lib/fluent/plugin/buffer/file_chunk.rb +364 -0
- data/lib/fluent/plugin/buffer/memory_chunk.rb +90 -0
- data/lib/fluent/plugin/compressable.rb +92 -0
- data/lib/fluent/plugin/exec_util.rb +22 -0
- data/lib/fluent/plugin/file_util.rb +22 -0
- data/lib/fluent/plugin/file_wrapper.rb +120 -0
- data/lib/fluent/plugin/filter.rb +93 -0
- data/lib/fluent/plugin/filter_grep.rb +75 -0
- data/lib/fluent/plugin/filter_parser.rb +119 -0
- data/lib/fluent/plugin/filter_record_transformer.rb +322 -0
- data/lib/fluent/plugin/filter_stdout.rb +53 -0
- data/lib/fluent/plugin/formatter.rb +50 -0
- data/lib/fluent/plugin/formatter_csv.rb +52 -0
- data/lib/fluent/plugin/formatter_hash.rb +33 -0
- data/lib/fluent/plugin/formatter_json.rb +55 -0
- data/lib/fluent/plugin/formatter_ltsv.rb +42 -0
- data/lib/fluent/plugin/formatter_msgpack.rb +33 -0
- data/lib/fluent/plugin/formatter_out_file.rb +51 -0
- data/lib/fluent/plugin/formatter_single_value.rb +34 -0
- data/lib/fluent/plugin/formatter_stdout.rb +75 -0
- data/lib/fluent/plugin/formatter_tsv.rb +34 -0
- data/lib/fluent/plugin/in_debug_agent.rb +64 -0
- data/lib/fluent/plugin/in_dummy.rb +139 -0
- data/lib/fluent/plugin/in_exec.rb +108 -0
- data/lib/fluent/plugin/in_forward.rb +455 -0
- data/lib/fluent/plugin/in_gc_stat.rb +56 -0
- data/lib/fluent/plugin/in_http.rb +433 -0
- data/lib/fluent/plugin/in_monitor_agent.rb +448 -0
- data/lib/fluent/plugin/in_object_space.rb +93 -0
- data/lib/fluent/plugin/in_syslog.rb +209 -0
- data/lib/fluent/plugin/in_tail.rb +905 -0
- data/lib/fluent/plugin/in_tcp.rb +85 -0
- data/lib/fluent/plugin/in_udp.rb +81 -0
- data/lib/fluent/plugin/in_unix.rb +201 -0
- data/lib/fluent/plugin/input.rb +37 -0
- data/lib/fluent/plugin/multi_output.rb +157 -0
- data/lib/fluent/plugin/out_copy.rb +46 -0
- data/lib/fluent/plugin/out_exec.rb +105 -0
- data/lib/fluent/plugin/out_exec_filter.rb +317 -0
- data/lib/fluent/plugin/out_file.rb +302 -0
- data/lib/fluent/plugin/out_forward.rb +912 -0
- data/lib/fluent/plugin/out_null.rb +74 -0
- data/lib/fluent/plugin/out_relabel.rb +32 -0
- data/lib/fluent/plugin/out_roundrobin.rb +84 -0
- data/lib/fluent/plugin/out_secondary_file.rb +133 -0
- data/lib/fluent/plugin/out_stdout.rb +75 -0
- data/lib/fluent/plugin/out_stream.rb +130 -0
- data/lib/fluent/plugin/output.rb +1291 -0
- data/lib/fluent/plugin/owned_by_mixin.rb +42 -0
- data/lib/fluent/plugin/parser.rb +191 -0
- data/lib/fluent/plugin/parser_apache.rb +28 -0
- data/lib/fluent/plugin/parser_apache2.rb +84 -0
- data/lib/fluent/plugin/parser_apache_error.rb +26 -0
- data/lib/fluent/plugin/parser_csv.rb +39 -0
- data/lib/fluent/plugin/parser_json.rb +81 -0
- data/lib/fluent/plugin/parser_ltsv.rb +42 -0
- data/lib/fluent/plugin/parser_msgpack.rb +50 -0
- data/lib/fluent/plugin/parser_multiline.rb +105 -0
- data/lib/fluent/plugin/parser_nginx.rb +28 -0
- data/lib/fluent/plugin/parser_none.rb +36 -0
- data/lib/fluent/plugin/parser_regexp.rb +63 -0
- data/lib/fluent/plugin/parser_syslog.rb +121 -0
- data/lib/fluent/plugin/parser_tsv.rb +42 -0
- data/lib/fluent/plugin/socket_util.rb +22 -0
- data/lib/fluent/plugin/storage.rb +84 -0
- data/lib/fluent/plugin/storage_local.rb +159 -0
- data/lib/fluent/plugin/string_util.rb +22 -0
- data/lib/fluent/plugin_helper.rb +70 -0
- data/lib/fluent/plugin_helper/cert_option.rb +159 -0
- data/lib/fluent/plugin_helper/child_process.rb +364 -0
- data/lib/fluent/plugin_helper/compat_parameters.rb +331 -0
- data/lib/fluent/plugin_helper/event_emitter.rb +93 -0
- data/lib/fluent/plugin_helper/event_loop.rb +161 -0
- data/lib/fluent/plugin_helper/extract.rb +104 -0
- data/lib/fluent/plugin_helper/formatter.rb +147 -0
- data/lib/fluent/plugin_helper/inject.rb +151 -0
- data/lib/fluent/plugin_helper/parser.rb +147 -0
- data/lib/fluent/plugin_helper/retry_state.rb +201 -0
- data/lib/fluent/plugin_helper/server.rb +738 -0
- data/lib/fluent/plugin_helper/socket.rb +241 -0
- data/lib/fluent/plugin_helper/socket_option.rb +69 -0
- data/lib/fluent/plugin_helper/storage.rb +349 -0
- data/lib/fluent/plugin_helper/thread.rb +179 -0
- data/lib/fluent/plugin_helper/timer.rb +91 -0
- data/lib/fluent/plugin_id.rb +80 -0
- data/lib/fluent/process.rb +22 -0
- data/lib/fluent/registry.rb +116 -0
- data/lib/fluent/root_agent.rb +323 -0
- data/lib/fluent/rpc.rb +94 -0
- data/lib/fluent/supervisor.rb +741 -0
- data/lib/fluent/system_config.rb +159 -0
- data/lib/fluent/test.rb +58 -0
- data/lib/fluent/test/base.rb +78 -0
- data/lib/fluent/test/driver/base.rb +224 -0
- data/lib/fluent/test/driver/base_owned.rb +70 -0
- data/lib/fluent/test/driver/base_owner.rb +135 -0
- data/lib/fluent/test/driver/event_feeder.rb +98 -0
- data/lib/fluent/test/driver/filter.rb +57 -0
- data/lib/fluent/test/driver/formatter.rb +30 -0
- data/lib/fluent/test/driver/input.rb +31 -0
- data/lib/fluent/test/driver/multi_output.rb +53 -0
- data/lib/fluent/test/driver/output.rb +102 -0
- data/lib/fluent/test/driver/parser.rb +30 -0
- data/lib/fluent/test/driver/test_event_router.rb +45 -0
- data/lib/fluent/test/filter_test.rb +77 -0
- data/lib/fluent/test/formatter_test.rb +65 -0
- data/lib/fluent/test/helpers.rb +134 -0
- data/lib/fluent/test/input_test.rb +174 -0
- data/lib/fluent/test/log.rb +79 -0
- data/lib/fluent/test/output_test.rb +156 -0
- data/lib/fluent/test/parser_test.rb +70 -0
- data/lib/fluent/test/startup_shutdown.rb +46 -0
- data/lib/fluent/time.rb +412 -0
- data/lib/fluent/timezone.rb +133 -0
- data/lib/fluent/unique_id.rb +39 -0
- data/lib/fluent/version.rb +21 -0
- data/lib/fluent/winsvc.rb +71 -0
- data/templates/new_gem/Gemfile +3 -0
- data/templates/new_gem/README.md.erb +43 -0
- data/templates/new_gem/Rakefile +13 -0
- data/templates/new_gem/fluent-plugin.gemspec.erb +27 -0
- data/templates/new_gem/lib/fluent/plugin/filter.rb.erb +14 -0
- data/templates/new_gem/lib/fluent/plugin/formatter.rb.erb +14 -0
- data/templates/new_gem/lib/fluent/plugin/input.rb.erb +11 -0
- data/templates/new_gem/lib/fluent/plugin/output.rb.erb +11 -0
- data/templates/new_gem/lib/fluent/plugin/parser.rb.erb +15 -0
- data/templates/new_gem/test/helper.rb.erb +8 -0
- data/templates/new_gem/test/plugin/test_filter.rb.erb +18 -0
- data/templates/new_gem/test/plugin/test_formatter.rb.erb +18 -0
- data/templates/new_gem/test/plugin/test_input.rb.erb +18 -0
- data/templates/new_gem/test/plugin/test_output.rb.erb +18 -0
- data/templates/new_gem/test/plugin/test_parser.rb.erb +18 -0
- data/templates/plugin_config_formatter/param.md-compact.erb +25 -0
- data/templates/plugin_config_formatter/param.md.erb +34 -0
- data/templates/plugin_config_formatter/section.md.erb +12 -0
- data/test/command/test_binlog_reader.rb +346 -0
- data/test/command/test_fluentd.rb +618 -0
- data/test/command/test_plugin_config_formatter.rb +275 -0
- data/test/command/test_plugin_generator.rb +66 -0
- data/test/compat/test_calls_super.rb +166 -0
- data/test/compat/test_parser.rb +92 -0
- data/test/config/assertions.rb +42 -0
- data/test/config/test_config_parser.rb +513 -0
- data/test/config/test_configurable.rb +1587 -0
- data/test/config/test_configure_proxy.rb +566 -0
- data/test/config/test_dsl.rb +415 -0
- data/test/config/test_element.rb +403 -0
- data/test/config/test_literal_parser.rb +297 -0
- data/test/config/test_section.rb +184 -0
- data/test/config/test_system_config.rb +168 -0
- data/test/config/test_types.rb +191 -0
- data/test/helper.rb +153 -0
- data/test/plugin/data/2010/01/20100102-030405.log +0 -0
- data/test/plugin/data/2010/01/20100102-030406.log +0 -0
- data/test/plugin/data/2010/01/20100102.log +0 -0
- data/test/plugin/data/log/bar +0 -0
- data/test/plugin/data/log/foo/bar.log +0 -0
- data/test/plugin/data/log/foo/bar2 +0 -0
- data/test/plugin/data/log/test.log +0 -0
- data/test/plugin/test_bare_output.rb +118 -0
- data/test/plugin/test_base.rb +115 -0
- data/test/plugin/test_buf_file.rb +843 -0
- data/test/plugin/test_buf_memory.rb +42 -0
- data/test/plugin/test_buffer.rb +1220 -0
- data/test/plugin/test_buffer_chunk.rb +198 -0
- data/test/plugin/test_buffer_file_chunk.rb +844 -0
- data/test/plugin/test_buffer_memory_chunk.rb +338 -0
- data/test/plugin/test_compressable.rb +84 -0
- data/test/plugin/test_file_util.rb +96 -0
- data/test/plugin/test_filter.rb +357 -0
- data/test/plugin/test_filter_grep.rb +119 -0
- data/test/plugin/test_filter_parser.rb +700 -0
- data/test/plugin/test_filter_record_transformer.rb +556 -0
- data/test/plugin/test_filter_stdout.rb +202 -0
- data/test/plugin/test_formatter_csv.rb +111 -0
- data/test/plugin/test_formatter_hash.rb +35 -0
- data/test/plugin/test_formatter_json.rb +51 -0
- data/test/plugin/test_formatter_ltsv.rb +59 -0
- data/test/plugin/test_formatter_msgpack.rb +28 -0
- data/test/plugin/test_formatter_out_file.rb +95 -0
- data/test/plugin/test_formatter_single_value.rb +38 -0
- data/test/plugin/test_in_debug_agent.rb +28 -0
- data/test/plugin/test_in_dummy.rb +192 -0
- data/test/plugin/test_in_exec.rb +245 -0
- data/test/plugin/test_in_forward.rb +1120 -0
- data/test/plugin/test_in_gc_stat.rb +39 -0
- data/test/plugin/test_in_http.rb +588 -0
- data/test/plugin/test_in_monitor_agent.rb +516 -0
- data/test/plugin/test_in_object_space.rb +64 -0
- data/test/plugin/test_in_syslog.rb +271 -0
- data/test/plugin/test_in_tail.rb +1216 -0
- data/test/plugin/test_in_tcp.rb +118 -0
- data/test/plugin/test_in_udp.rb +152 -0
- data/test/plugin/test_in_unix.rb +126 -0
- data/test/plugin/test_input.rb +126 -0
- data/test/plugin/test_multi_output.rb +180 -0
- data/test/plugin/test_out_copy.rb +160 -0
- data/test/plugin/test_out_exec.rb +310 -0
- data/test/plugin/test_out_exec_filter.rb +613 -0
- data/test/plugin/test_out_file.rb +873 -0
- data/test/plugin/test_out_forward.rb +685 -0
- data/test/plugin/test_out_null.rb +105 -0
- data/test/plugin/test_out_relabel.rb +28 -0
- data/test/plugin/test_out_roundrobin.rb +146 -0
- data/test/plugin/test_out_secondary_file.rb +442 -0
- data/test/plugin/test_out_stdout.rb +170 -0
- data/test/plugin/test_out_stream.rb +93 -0
- data/test/plugin/test_output.rb +870 -0
- data/test/plugin/test_output_as_buffered.rb +1932 -0
- data/test/plugin/test_output_as_buffered_compress.rb +165 -0
- data/test/plugin/test_output_as_buffered_overflow.rb +250 -0
- data/test/plugin/test_output_as_buffered_retries.rb +839 -0
- data/test/plugin/test_output_as_buffered_secondary.rb +877 -0
- data/test/plugin/test_output_as_standard.rb +374 -0
- data/test/plugin/test_owned_by.rb +35 -0
- data/test/plugin/test_parser.rb +359 -0
- data/test/plugin/test_parser_apache.rb +42 -0
- data/test/plugin/test_parser_apache2.rb +46 -0
- data/test/plugin/test_parser_apache_error.rb +45 -0
- data/test/plugin/test_parser_csv.rb +103 -0
- data/test/plugin/test_parser_json.rb +114 -0
- data/test/plugin/test_parser_labeled_tsv.rb +128 -0
- data/test/plugin/test_parser_multiline.rb +100 -0
- data/test/plugin/test_parser_nginx.rb +48 -0
- data/test/plugin/test_parser_none.rb +52 -0
- data/test/plugin/test_parser_regexp.rb +281 -0
- data/test/plugin/test_parser_syslog.rb +242 -0
- data/test/plugin/test_parser_tsv.rb +122 -0
- data/test/plugin/test_storage.rb +167 -0
- data/test/plugin/test_storage_local.rb +335 -0
- data/test/plugin/test_string_util.rb +26 -0
- data/test/plugin_helper/test_child_process.rb +794 -0
- data/test/plugin_helper/test_compat_parameters.rb +331 -0
- data/test/plugin_helper/test_event_emitter.rb +51 -0
- data/test/plugin_helper/test_event_loop.rb +52 -0
- data/test/plugin_helper/test_extract.rb +194 -0
- data/test/plugin_helper/test_formatter.rb +255 -0
- data/test/plugin_helper/test_inject.rb +519 -0
- data/test/plugin_helper/test_parser.rb +264 -0
- data/test/plugin_helper/test_retry_state.rb +422 -0
- data/test/plugin_helper/test_server.rb +1677 -0
- data/test/plugin_helper/test_storage.rb +542 -0
- data/test/plugin_helper/test_thread.rb +164 -0
- data/test/plugin_helper/test_timer.rb +132 -0
- data/test/scripts/exec_script.rb +32 -0
- data/test/scripts/fluent/plugin/formatter1/formatter_test1.rb +7 -0
- data/test/scripts/fluent/plugin/formatter2/formatter_test2.rb +7 -0
- data/test/scripts/fluent/plugin/formatter_known.rb +8 -0
- data/test/scripts/fluent/plugin/out_test.rb +81 -0
- data/test/scripts/fluent/plugin/out_test2.rb +80 -0
- data/test/scripts/fluent/plugin/parser_known.rb +4 -0
- data/test/test_clock.rb +164 -0
- data/test/test_config.rb +179 -0
- data/test/test_configdsl.rb +148 -0
- data/test/test_event.rb +515 -0
- data/test/test_event_router.rb +331 -0
- data/test/test_event_time.rb +186 -0
- data/test/test_filter.rb +121 -0
- data/test/test_formatter.rb +312 -0
- data/test/test_input.rb +31 -0
- data/test/test_log.rb +828 -0
- data/test/test_match.rb +137 -0
- data/test/test_mixin.rb +351 -0
- data/test/test_output.rb +273 -0
- data/test/test_plugin.rb +251 -0
- data/test/test_plugin_classes.rb +253 -0
- data/test/test_plugin_helper.rb +81 -0
- data/test/test_plugin_id.rb +101 -0
- data/test/test_process.rb +14 -0
- data/test/test_root_agent.rb +611 -0
- data/test/test_supervisor.rb +373 -0
- data/test/test_test_drivers.rb +135 -0
- data/test/test_time_formatter.rb +282 -0
- data/test/test_time_parser.rb +211 -0
- data/test/test_unique_id.rb +47 -0
- metadata +898 -0
@@ -0,0 +1,100 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
require 'fluent/test/driver/parser'
|
3
|
+
require 'fluent/plugin/parser'
|
4
|
+
|
5
|
+
class MultilineParserTest < ::Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
Fluent::Test.setup
|
8
|
+
end
|
9
|
+
|
10
|
+
def create_parser(conf)
|
11
|
+
parser = Fluent::Test::Driver::Parser.new(Fluent::Plugin::MultilineParser).configure(conf)
|
12
|
+
parser
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_configure_with_invalid_params
|
16
|
+
[{'format100' => '/(?<msg>.*)/'}, {'format1' => '/(?<msg>.*)/', 'format3' => '/(?<msg>.*)/'}, 'format1' => '/(?<msg>.*)'].each { |config|
|
17
|
+
assert_raise(Fluent::ConfigError) {
|
18
|
+
create_parser(config)
|
19
|
+
}
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_parse
|
24
|
+
parser = create_parser('format1' => '/^(?<time>\d{4}-\d{1,2}-\d{1,2} \d{1,2}:\d{1,2}:\d{1,2}) \[(?<thread>.*)\] (?<level>[^\s]+)(?<message>.*)/')
|
25
|
+
parser.instance.parse(<<EOS.chomp) { |time, record|
|
26
|
+
2013-3-03 14:27:33 [main] ERROR Main - Exception
|
27
|
+
javax.management.RuntimeErrorException: null
|
28
|
+
\tat Main.main(Main.java:16) ~[bin/:na]
|
29
|
+
EOS
|
30
|
+
|
31
|
+
assert_equal(event_time('2013-3-03 14:27:33').to_i, time)
|
32
|
+
assert_equal({
|
33
|
+
"thread" => "main",
|
34
|
+
"level" => "ERROR",
|
35
|
+
"message" => " Main - Exception\njavax.management.RuntimeErrorException: null\n\tat Main.main(Main.java:16) ~[bin/:na]"
|
36
|
+
}, record)
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_parse_with_firstline
|
41
|
+
parser = create_parser('format_firstline' => '/----/', 'format1' => '/time=(?<time>\d{4}-\d{1,2}-\d{1,2} \d{1,2}:\d{1,2}:\d{1,2}).*message=(?<message>.*)/')
|
42
|
+
parser.instance.parse(<<EOS.chomp) { |time, record|
|
43
|
+
----
|
44
|
+
time=2013-3-03 14:27:33
|
45
|
+
message=test1
|
46
|
+
EOS
|
47
|
+
|
48
|
+
assert(parser.instance.firstline?('----'))
|
49
|
+
assert_equal(event_time('2013-3-03 14:27:33').to_i, time)
|
50
|
+
assert_equal({"message" => "test1"}, record)
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_parse_with_multiple_formats
|
55
|
+
parser = create_parser('format_firstline' => '/^Started/',
|
56
|
+
'format1' => '/Started (?<method>[^ ]+) "(?<path>[^"]+)" for (?<host>[^ ]+) at (?<time>[^ ]+ [^ ]+ [^ ]+)\n/',
|
57
|
+
'format2' => '/Processing by (?<controller>[^\u0023]+)\u0023(?<controller_method>[^ ]+) as (?<format>[^ ]+?)\n/',
|
58
|
+
'format3' => '/( Parameters: (?<parameters>[^ ]+)\n)?/',
|
59
|
+
'format4' => '/ Rendered (?<template>[^ ]+) within (?<layout>.+) \([\d\.]+ms\)\n/',
|
60
|
+
'format5' => '/Completed (?<code>[^ ]+) [^ ]+ in (?<runtime>[\d\.]+)ms \(Views: (?<view_runtime>[\d\.]+)ms \| ActiveRecord: (?<ar_runtime>[\d\.]+)ms\)/'
|
61
|
+
)
|
62
|
+
parser.instance.parse(<<EOS.chomp) { |time, record|
|
63
|
+
Started GET "/users/123/" for 127.0.0.1 at 2013-06-14 12:00:11 +0900
|
64
|
+
Processing by UsersController#show as HTML
|
65
|
+
Parameters: {"user_id"=>"123"}
|
66
|
+
Rendered users/show.html.erb within layouts/application (0.3ms)
|
67
|
+
Completed 200 OK in 4ms (Views: 3.2ms | ActiveRecord: 0.0ms)
|
68
|
+
EOS
|
69
|
+
|
70
|
+
assert(parser.instance.firstline?('Started GET "/users/123/" for 127.0.0.1...'))
|
71
|
+
assert_equal(event_time('2013-06-14 12:00:11 +0900').to_i, time)
|
72
|
+
assert_equal({
|
73
|
+
"method" => "GET",
|
74
|
+
"path" => "/users/123/",
|
75
|
+
"host" => "127.0.0.1",
|
76
|
+
"controller" => "UsersController",
|
77
|
+
"controller_method" => "show",
|
78
|
+
"format" => "HTML",
|
79
|
+
"parameters" => "{\"user_id\"=>\"123\"}",
|
80
|
+
"template" => "users/show.html.erb",
|
81
|
+
"layout" => "layouts/application",
|
82
|
+
"code" => "200",
|
83
|
+
"runtime" => "4",
|
84
|
+
"view_runtime" => "3.2",
|
85
|
+
"ar_runtime" => "0.0"
|
86
|
+
}, record)
|
87
|
+
}
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_parse_with_keep_time_key
|
91
|
+
parser = Fluent::Test::Driver::Parser.new(Fluent::Plugin::MultilineParser).configure(
|
92
|
+
'format1' => '/^(?<time>\d{4}-\d{1,2}-\d{1,2} \d{1,2}:\d{1,2}:\d{1,2})/',
|
93
|
+
'keep_time_key' => 'true'
|
94
|
+
)
|
95
|
+
text = '2013-3-03 14:27:33'
|
96
|
+
parser.instance.parse(text) { |time, record|
|
97
|
+
assert_equal text, record['time']
|
98
|
+
}
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
require 'fluent/test/driver/parser'
|
3
|
+
require 'fluent/plugin/parser_nginx'
|
4
|
+
|
5
|
+
class NginxParserTest < ::Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
Fluent::Test.setup
|
8
|
+
@expected = {
|
9
|
+
'remote' => '127.0.0.1',
|
10
|
+
'host' => '192.168.0.1',
|
11
|
+
'user' => '-',
|
12
|
+
'method' => 'GET',
|
13
|
+
'path' => '/',
|
14
|
+
'code' => '200',
|
15
|
+
'size' => '777',
|
16
|
+
'referer' => '-',
|
17
|
+
'agent' => 'Opera/12.0'
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
def create_driver
|
22
|
+
Fluent::Test::Driver::Parser.new(Fluent::Plugin::NginxParser.new).configure({})
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_parse
|
26
|
+
d = create_driver
|
27
|
+
d.instance.parse('127.0.0.1 192.168.0.1 - [28/Feb/2013:12:00:00 +0900] "GET / HTTP/1.1" 200 777 "-" "Opera/12.0"') { |time, record|
|
28
|
+
assert_equal(event_time('28/Feb/2013:12:00:00 +0900', format: '%d/%b/%Y:%H:%M:%S %z'), time)
|
29
|
+
assert_equal(@expected, record)
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_parse_with_empty_included_path
|
34
|
+
d = create_driver
|
35
|
+
d.instance.parse('127.0.0.1 192.168.0.1 - [28/Feb/2013:12:00:00 +0900] "GET /a[ ]b HTTP/1.1" 200 777 "-" "Opera/12.0"') { |time, record|
|
36
|
+
assert_equal(event_time('28/Feb/2013:12:00:00 +0900', format: '%d/%b/%Y:%H:%M:%S %z'), time)
|
37
|
+
assert_equal(@expected.merge('path' => '/a[ ]b'), record)
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_parse_without_http_version
|
42
|
+
d = create_driver
|
43
|
+
d.instance.parse('127.0.0.1 192.168.0.1 - [28/Feb/2013:12:00:00 +0900] "GET /" 200 777 "-" "Opera/12.0"') { |time, record|
|
44
|
+
assert_equal(event_time('28/Feb/2013:12:00:00 +0900', format: '%d/%b/%Y:%H:%M:%S %z'), time)
|
45
|
+
assert_equal(@expected, record)
|
46
|
+
}
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
require 'fluent/test/driver/parser'
|
3
|
+
require 'fluent/plugin/parser'
|
4
|
+
|
5
|
+
class NoneParserTest < ::Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
Fluent::Test.setup
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_config_params
|
11
|
+
parser = Fluent::Test::Driver::Parser.new(Fluent::TextParser::NoneParser)
|
12
|
+
parser.configure({})
|
13
|
+
assert_equal "message", parser.instance.message_key
|
14
|
+
|
15
|
+
parser.configure('message_key' => 'foobar')
|
16
|
+
assert_equal "foobar", parser.instance.message_key
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_parse
|
20
|
+
parser = Fluent::Test::Driver::Parser.new(Fluent::Plugin.new_parser('none'))
|
21
|
+
parser.configure({})
|
22
|
+
parser.instance.parse('log message!') { |time, record|
|
23
|
+
assert_equal({'message' => 'log message!'}, record)
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_parse_with_message_key
|
28
|
+
parser = Fluent::Test::Driver::Parser.new(Fluent::TextParser::NoneParser)
|
29
|
+
parser.configure('message_key' => 'foobar')
|
30
|
+
parser.instance.parse('log message!') { |time, record|
|
31
|
+
assert_equal({'foobar' => 'log message!'}, record)
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_parse_without_default_time
|
36
|
+
time_at_start = Time.now.to_i
|
37
|
+
|
38
|
+
parser = Fluent::Test::Driver::Parser.new(Fluent::Plugin.new_parser('none'))
|
39
|
+
parser.configure({})
|
40
|
+
parser.instance.parse('log message!') { |time, record|
|
41
|
+
assert time && time >= time_at_start, "parser puts current time without time input"
|
42
|
+
assert_equal({'message' => 'log message!'}, record)
|
43
|
+
}
|
44
|
+
|
45
|
+
parser = Fluent::Test::Driver::Parser.new(Fluent::Plugin.new_parser('none'))
|
46
|
+
parser.configure({'estimate_current_event' => 'false'})
|
47
|
+
parser.instance.parse('log message!') { |time, record|
|
48
|
+
assert_equal({'message' => 'log message!'}, record)
|
49
|
+
assert_nil time, "parser returns nil w/o time if configured so"
|
50
|
+
}
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,281 @@
|
|
1
|
+
require_relative '../helper'
|
2
|
+
require 'fluent/test/driver/parser'
|
3
|
+
require 'fluent/plugin/parser'
|
4
|
+
|
5
|
+
class RegexpParserTest < ::Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
Fluent::Test.setup
|
8
|
+
end
|
9
|
+
|
10
|
+
def internal_test_case(parser)
|
11
|
+
text = '192.168.0.1 - - [28/Feb/2013:12:00:00 +0900] [14/Feb/2013:12:00:00 +0900] "true /,/user HTTP/1.1" 200 777'
|
12
|
+
parser.parse(text) { |time, record|
|
13
|
+
assert_equal(event_time('28/Feb/2013:12:00:00 +0900', format: '%d/%b/%Y:%H:%M:%S %z'), time)
|
14
|
+
assert_equal({
|
15
|
+
'user' => '-',
|
16
|
+
'flag' => true,
|
17
|
+
'code' => 200.0,
|
18
|
+
'size' => 777,
|
19
|
+
'date' => event_time('14/Feb/2013:12:00:00 +0900', format: '%d/%b/%Y:%H:%M:%S %z'),
|
20
|
+
'host' => '192.168.0.1',
|
21
|
+
'path' => ['/', '/user']
|
22
|
+
}, record)
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
sub_test_case "Fluent::Compat::TextParser::RegexpParser" do
|
27
|
+
def create_driver(regexp, conf = {}, initialize_conf: false)
|
28
|
+
if initialize_conf
|
29
|
+
Fluent::Test::Driver::Parser.new(Fluent::Compat::TextParser::RegexpParser.new(regexp, conf))
|
30
|
+
else
|
31
|
+
# Fluent::Test::Driver::Parser.new(Fluent::Compat::TextParser::RegexpParser.new(regexp)).configure(conf)
|
32
|
+
instance = Fluent::Compat::TextParser::RegexpParser.new(regexp)
|
33
|
+
instance.configure(conf)
|
34
|
+
d = Struct.new(:instance).new
|
35
|
+
d.instance = instance
|
36
|
+
d
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_parse_with_typed
|
41
|
+
# Use Regexp.new instead of // literal to avoid different parser behaviour in 1.9 and 2.0
|
42
|
+
regexp = Regexp.new(%q!^(?<host>[^ ]*) [^ ]* (?<user>[^ ]*) \[(?<time>[^\]]*)\] \[(?<date>[^\]]*)\] "(?<flag>\S+)(?: +(?<path>[^ ]*) +\S*)?" (?<code>[^ ]*) (?<size>[^ ]*)$!)
|
43
|
+
conf = {
|
44
|
+
'time_format' => "%d/%b/%Y:%H:%M:%S %z",
|
45
|
+
'types' => 'user:string,date:time:%d/%b/%Y:%H:%M:%S %z,flag:bool,path:array,code:float,size:integer'
|
46
|
+
}
|
47
|
+
d = create_driver(regexp, conf, initialize_conf: true)
|
48
|
+
internal_test_case(d.instance)
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_parse_with_configure
|
52
|
+
# Specify conf by configure method instead of initializer
|
53
|
+
regexp = Regexp.new(%q!^(?<host>[^ ]*) [^ ]* (?<user>[^ ]*) \[(?<time>[^\]]*)\] \[(?<date>[^\]]*)\] "(?<flag>\S+)(?: +(?<path>[^ ]*) +\S*)?" (?<code>[^ ]*) (?<size>[^ ]*)$!)
|
54
|
+
conf = {
|
55
|
+
'time_format' => "%d/%b/%Y:%H:%M:%S %z",
|
56
|
+
'types' => 'user:string,date:time:%d/%b/%Y:%H:%M:%S %z,flag:bool,path:array,code:float,size:integer'
|
57
|
+
}
|
58
|
+
d = create_driver(regexp, conf)
|
59
|
+
internal_test_case(d.instance)
|
60
|
+
assert_equal(regexp, d.instance.patterns['format'])
|
61
|
+
assert_equal("%d/%b/%Y:%H:%M:%S %z", d.instance.patterns['time_format'])
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_parse_with_typed_and_name_separator
|
65
|
+
regexp = Regexp.new(%q!^(?<host>[^ ]*) [^ ]* (?<user>[^ ]*) \[(?<time>[^\]]*)\] \[(?<date>[^\]]*)\] "(?<flag>\S+)(?: +(?<path>[^ ]*) +\S*)?" (?<code>[^ ]*) (?<size>[^ ]*)$!)
|
66
|
+
conf = {
|
67
|
+
'time_format' => "%d/%b/%Y:%H:%M:%S %z",
|
68
|
+
'types' => 'user|string,date|time|%d/%b/%Y:%H:%M:%S %z,flag|bool,path|array,code|float,size|integer',
|
69
|
+
'types_label_delimiter' => '|'
|
70
|
+
}
|
71
|
+
d = create_driver(regexp, conf)
|
72
|
+
internal_test_case(d.instance)
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_parse_with_time_key
|
76
|
+
conf = {
|
77
|
+
'time_format' => "%Y-%m-%d %H:%M:%S %z",
|
78
|
+
'time_key' => 'logtime'
|
79
|
+
}
|
80
|
+
d = create_driver(/(?<logtime>[^\]]*)/, conf)
|
81
|
+
text = '2013-02-28 12:00:00 +0900'
|
82
|
+
d.instance.parse(text) do |time, _record|
|
83
|
+
assert_equal Fluent::EventTime.parse(text), time
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_parse_without_time
|
88
|
+
time_at_start = Time.now.to_i
|
89
|
+
text = "tagomori_satoshi tagomoris 34\n"
|
90
|
+
|
91
|
+
regexp = Regexp.new(%q!^(?<name>[^ ]*) (?<user>[^ ]*) (?<age>\d*)$!)
|
92
|
+
conf = {
|
93
|
+
'types' => 'name:string,user:string,age:integer'
|
94
|
+
}
|
95
|
+
d = create_driver(regexp, conf)
|
96
|
+
|
97
|
+
d.instance.parse(text) { |time, record|
|
98
|
+
assert time && time >= time_at_start, "parser puts current time without time input"
|
99
|
+
assert_equal "tagomori_satoshi", record["name"]
|
100
|
+
assert_equal "tagomoris", record["user"]
|
101
|
+
assert_equal 34, record["age"]
|
102
|
+
}
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_parse_without_time_estimate_curent_event_false
|
106
|
+
text = "tagomori_satoshi tagomoris 34\n"
|
107
|
+
regexp = Regexp.new(%q!^(?<name>[^ ]*) (?<user>[^ ]*) (?<age>\d*)$!)
|
108
|
+
conf = {
|
109
|
+
'types' => 'name:string,user:string,age:integer'
|
110
|
+
}
|
111
|
+
d = create_driver(regexp, conf)
|
112
|
+
d.instance.estimate_current_event = false
|
113
|
+
d.instance.parse(text) { |time, record|
|
114
|
+
assert_equal "tagomori_satoshi", record["name"]
|
115
|
+
assert_equal "tagomoris", record["user"]
|
116
|
+
assert_equal 34, record["age"]
|
117
|
+
|
118
|
+
assert_nil time, "parser returns nil if configured so"
|
119
|
+
}
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_parse_with_keep_time_key
|
123
|
+
regexp = Regexp.new(%q!(?<time>.*)!)
|
124
|
+
conf = {
|
125
|
+
'time_format' => "%d/%b/%Y:%H:%M:%S %z",
|
126
|
+
'keep_time_key' => 'true',
|
127
|
+
}
|
128
|
+
d = create_driver(regexp, conf)
|
129
|
+
text = '28/Feb/2013:12:00:00 +0900'
|
130
|
+
d.instance.parse(text) do |_time, record|
|
131
|
+
assert_equal text, record['time']
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_parse_with_keep_time_key_with_typecast
|
136
|
+
regexp = Regexp.new(%q!(?<time>.*)!)
|
137
|
+
conf = {
|
138
|
+
'time_format' => "%d/%b/%Y:%H:%M:%S %z",
|
139
|
+
'keep_time_key' => 'true',
|
140
|
+
'types' => 'time:time:%d/%b/%Y:%H:%M:%S %z',
|
141
|
+
}
|
142
|
+
d = create_driver(regexp, conf)
|
143
|
+
text = '28/Feb/2013:12:00:00 +0900'
|
144
|
+
d.instance.parse(text) do |_time, record|
|
145
|
+
assert_equal 1362020400, record['time']
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
sub_test_case "Fluent::Plugin::RegexpParser" do
|
151
|
+
def create_driver(conf)
|
152
|
+
Fluent::Test::Driver::Parser.new(Fluent::Plugin::RegexpParser.new).configure(conf)
|
153
|
+
end
|
154
|
+
|
155
|
+
sub_test_case "configure" do
|
156
|
+
def test_default_options
|
157
|
+
conf = {
|
158
|
+
'expression' => %q!/^(?<host>[^ ]*) [^ ]* (?<user>[^ ]*) \[(?<time>[^\]]*)\] \[(?<date>[^\]]*)\] "(?<flag>\S+)(?: +(?<path>[^ ]*) +\S*)?" (?<code>[^ ]*) (?<size>[^ ]*)$/!,
|
159
|
+
'time_format' => "%d/%b/%Y:%H:%M:%S %z",
|
160
|
+
'types' => 'user:string,date:time:%d/%b/%Y:%H:%M:%S %z,flag:bool,path:array,code:float,size:integer'
|
161
|
+
}
|
162
|
+
d = create_driver(conf)
|
163
|
+
regexp = d.instance.instance_variable_get(:@regexp)
|
164
|
+
assert_equal(0, regexp.options)
|
165
|
+
end
|
166
|
+
|
167
|
+
data(
|
168
|
+
ignorecase: [{ "ignorecase" => true }, Regexp::IGNORECASE],
|
169
|
+
multiline: [{ "multiline" => true }, Regexp::MULTILINE],
|
170
|
+
ignorecase_multiline: [{ "ignorecase" => true, "multiline" => true }, Regexp::IGNORECASE | Regexp::MULTILINE],
|
171
|
+
)
|
172
|
+
def test_options(data)
|
173
|
+
regexp_option, expected = data
|
174
|
+
conf = {
|
175
|
+
'expression' => %q!/^(?<host>[^ ]*) [^ ]* (?<user>[^ ]*) \[(?<time>[^\]]*)\] \[(?<date>[^\]]*)\] "(?<flag>\S+)(?: +(?<path>[^ ]*) +\S*)?" (?<code>[^ ]*) (?<size>[^ ]*)$/!,
|
176
|
+
'time_format' => "%d/%b/%Y:%H:%M:%S %z",
|
177
|
+
'types' => 'user:string,date:time:%d/%b/%Y:%H:%M:%S %z,flag:bool,path:array,code:float,size:integer'
|
178
|
+
}
|
179
|
+
conf = conf.merge(regexp_option)
|
180
|
+
d = create_driver(conf)
|
181
|
+
regexp = d.instance.instance_variable_get(:@regexp)
|
182
|
+
assert_equal(expected, regexp.options)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
def test_parse_with_typed
|
187
|
+
conf = {
|
188
|
+
'expression' => %q!/^(?<host>[^ ]*) [^ ]* (?<user>[^ ]*) \[(?<time>[^\]]*)\] \[(?<date>[^\]]*)\] "(?<flag>\S+)(?: +(?<path>[^ ]*) +\S*)?" (?<code>[^ ]*) (?<size>[^ ]*)$/!,
|
189
|
+
'time_format' => "%d/%b/%Y:%H:%M:%S %z",
|
190
|
+
'types' => 'user:string,date:time:%d/%b/%Y:%H:%M:%S %z,flag:bool,path:array,code:float,size:integer'
|
191
|
+
}
|
192
|
+
d = create_driver(conf)
|
193
|
+
internal_test_case(d.instance)
|
194
|
+
end
|
195
|
+
|
196
|
+
def test_parse_with_typed_by_json_hash
|
197
|
+
conf = {
|
198
|
+
'expression' => %q!/^(?<host>[^ ]*) [^ ]* (?<user>[^ ]*) \[(?<time>[^\]]*)\] \[(?<date>[^\]]*)\] "(?<flag>\S+)(?: +(?<path>[^ ]*) +\S*)?" (?<code>[^ ]*) (?<size>[^ ]*)$/!,
|
199
|
+
'time_format' => "%d/%b/%Y:%H:%M:%S %z",
|
200
|
+
'types' => '{"user":"string","date":"time:%d/%b/%Y:%H:%M:%S %z","flag":"bool","path":"array","code":"float","size":"integer"}',
|
201
|
+
}
|
202
|
+
d = create_driver(conf)
|
203
|
+
internal_test_case(d.instance)
|
204
|
+
end
|
205
|
+
|
206
|
+
def test_parse_with_time_key
|
207
|
+
conf = {
|
208
|
+
'expression' => %q!/(?<logtime>[^\]]*)/!,
|
209
|
+
'time_format' => "%Y-%m-%d %H:%M:%S %z",
|
210
|
+
'time_key' => 'logtime'
|
211
|
+
}
|
212
|
+
d = create_driver(conf)
|
213
|
+
text = '2013-02-28 12:00:00 +0900'
|
214
|
+
d.instance.parse(text) do |time, _record|
|
215
|
+
assert_equal Fluent::EventTime.parse(text), time
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
def test_parse_without_time
|
220
|
+
time_at_start = Time.now.to_i
|
221
|
+
text = "tagomori_satoshi tagomoris 34\n"
|
222
|
+
|
223
|
+
conf = {
|
224
|
+
'expression' => %q!/^(?<name>[^ ]*) (?<user>[^ ]*) (?<age>\d*)$/!,
|
225
|
+
'types' => 'name:string,user:string,age:integer'
|
226
|
+
}
|
227
|
+
d = create_driver(conf)
|
228
|
+
|
229
|
+
d.instance.parse(text) { |time, record|
|
230
|
+
assert time && time >= time_at_start, "parser puts current time without time input"
|
231
|
+
assert_equal "tagomori_satoshi", record["name"]
|
232
|
+
assert_equal "tagomoris", record["user"]
|
233
|
+
assert_equal 34, record["age"]
|
234
|
+
}
|
235
|
+
end
|
236
|
+
|
237
|
+
def test_parse_without_time_estimate_curent_event_false
|
238
|
+
text = "tagomori_satoshi tagomoris 34\n"
|
239
|
+
conf = {
|
240
|
+
'expression' => %q!/^(?<name>[^ ]*) (?<user>[^ ]*) (?<age>\d*)$/!,
|
241
|
+
'types' => 'name:string,user:string,age:integer'
|
242
|
+
}
|
243
|
+
d = create_driver(conf)
|
244
|
+
d.instance.estimate_current_event = false
|
245
|
+
d.instance.parse(text) { |time, record|
|
246
|
+
assert_equal "tagomori_satoshi", record["name"]
|
247
|
+
assert_equal "tagomoris", record["user"]
|
248
|
+
assert_equal 34, record["age"]
|
249
|
+
|
250
|
+
assert_nil time, "parser returns nil if configured so"
|
251
|
+
}
|
252
|
+
end
|
253
|
+
|
254
|
+
def test_parse_with_keep_time_key
|
255
|
+
conf = {
|
256
|
+
'expression' => %q!/(?<time>.*)/!,
|
257
|
+
'time_format' => "%d/%b/%Y:%H:%M:%S %z",
|
258
|
+
'keep_time_key' => 'true',
|
259
|
+
}
|
260
|
+
d = create_driver(conf)
|
261
|
+
text = '28/Feb/2013:12:00:00 +0900'
|
262
|
+
d.instance.parse(text) do |_time, record|
|
263
|
+
assert_equal text, record['time']
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
def test_parse_with_keep_time_key_with_typecast
|
268
|
+
conf = {
|
269
|
+
'expression' => %q!/(?<time>.*)/!,
|
270
|
+
'time_format' => "%d/%b/%Y:%H:%M:%S %z",
|
271
|
+
'keep_time_key' => 'true',
|
272
|
+
'types' => 'time:time:%d/%b/%Y:%H:%M:%S %z',
|
273
|
+
}
|
274
|
+
d = create_driver(conf)
|
275
|
+
text = '28/Feb/2013:12:00:00 +0900'
|
276
|
+
d.instance.parse(text) do |_time, record|
|
277
|
+
assert_equal 1362020400, record['time']
|
278
|
+
end
|
279
|
+
end
|
280
|
+
end
|
281
|
+
end
|