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,90 @@
|
|
1
|
+
#
|
2
|
+
# Fluentd
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'fluent/plugin/buffer/chunk'
|
18
|
+
|
19
|
+
module Fluent
|
20
|
+
module Plugin
|
21
|
+
class Buffer
|
22
|
+
class MemoryChunk < Chunk
|
23
|
+
def initialize(metadata, compress: :text)
|
24
|
+
super
|
25
|
+
@chunk = ''.force_encoding(Encoding::ASCII_8BIT)
|
26
|
+
@chunk_bytes = 0
|
27
|
+
@adding_bytes = 0
|
28
|
+
@adding_size = 0
|
29
|
+
end
|
30
|
+
|
31
|
+
def concat(bulk, bulk_size)
|
32
|
+
raise "BUG: concatenating to unwritable chunk, now '#{self.state}'" unless self.writable?
|
33
|
+
|
34
|
+
bulk.force_encoding(Encoding::ASCII_8BIT)
|
35
|
+
@chunk << bulk
|
36
|
+
@adding_bytes += bulk.bytesize
|
37
|
+
@adding_size += bulk_size
|
38
|
+
true
|
39
|
+
end
|
40
|
+
|
41
|
+
def commit
|
42
|
+
@size += @adding_size
|
43
|
+
@chunk_bytes += @adding_bytes
|
44
|
+
|
45
|
+
@adding_bytes = @adding_size = 0
|
46
|
+
@modified_at = Time.now
|
47
|
+
true
|
48
|
+
end
|
49
|
+
|
50
|
+
def rollback
|
51
|
+
@chunk.slice!(@chunk_bytes, @adding_bytes)
|
52
|
+
@adding_bytes = @adding_size = 0
|
53
|
+
true
|
54
|
+
end
|
55
|
+
|
56
|
+
def bytesize
|
57
|
+
@chunk_bytes + @adding_bytes
|
58
|
+
end
|
59
|
+
|
60
|
+
def size
|
61
|
+
@size + @adding_size
|
62
|
+
end
|
63
|
+
|
64
|
+
def empty?
|
65
|
+
@chunk.empty?
|
66
|
+
end
|
67
|
+
|
68
|
+
def purge
|
69
|
+
super
|
70
|
+
@chunk = ''.force_encoding("ASCII-8BIT")
|
71
|
+
@chunk_bytes = @size = @adding_bytes = @adding_size = 0
|
72
|
+
true
|
73
|
+
end
|
74
|
+
|
75
|
+
def read(**kwargs)
|
76
|
+
@chunk
|
77
|
+
end
|
78
|
+
|
79
|
+
def open(**kwargs, &block)
|
80
|
+
StringIO.open(@chunk, &block)
|
81
|
+
end
|
82
|
+
|
83
|
+
def write_to(io, **kwargs)
|
84
|
+
# re-implementation to optimize not to create StringIO
|
85
|
+
io.write @chunk
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
#
|
2
|
+
# Fluentd
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'stringio'
|
18
|
+
require 'zlib'
|
19
|
+
|
20
|
+
module Fluent
|
21
|
+
module Plugin
|
22
|
+
module Compressable
|
23
|
+
def compress(data, **kwargs)
|
24
|
+
output_io = kwargs[:output_io]
|
25
|
+
io = output_io || StringIO.new
|
26
|
+
Zlib::GzipWriter.wrap(io) do |gz|
|
27
|
+
gz.write data
|
28
|
+
end
|
29
|
+
|
30
|
+
output_io || io.string
|
31
|
+
end
|
32
|
+
|
33
|
+
# compressed_data is String like `compress(data1) + compress(data2) + ... + compress(dataN)`
|
34
|
+
# https://www.ruby-forum.com/topic/971591#979503
|
35
|
+
def decompress(compressed_data = nil, output_io: nil, input_io: nil)
|
36
|
+
case
|
37
|
+
when input_io && output_io
|
38
|
+
io_decompress(input_io, output_io)
|
39
|
+
when input_io
|
40
|
+
output_io = StringIO.new
|
41
|
+
io = io_decompress(input_io, output_io)
|
42
|
+
io.string
|
43
|
+
when compressed_data.nil? || compressed_data.empty?
|
44
|
+
# check compressed_data(String) is 0 length
|
45
|
+
compressed_data
|
46
|
+
when output_io
|
47
|
+
# exeucte after checking compressed_data is empty or not
|
48
|
+
io = StringIO.new(compressed_data)
|
49
|
+
io_decompress(io, output_io)
|
50
|
+
else
|
51
|
+
string_decompress(compressed_data)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def string_decompress(compressed_data)
|
58
|
+
io = StringIO.new(compressed_data)
|
59
|
+
|
60
|
+
out = ''
|
61
|
+
loop do
|
62
|
+
gz = Zlib::GzipReader.new(io)
|
63
|
+
out += gz.read
|
64
|
+
unused = gz.unused
|
65
|
+
gz.finish
|
66
|
+
|
67
|
+
break if unused.nil?
|
68
|
+
adjust = unused.length
|
69
|
+
io.pos -= adjust
|
70
|
+
end
|
71
|
+
|
72
|
+
out
|
73
|
+
end
|
74
|
+
|
75
|
+
def io_decompress(input, output)
|
76
|
+
loop do
|
77
|
+
gz = Zlib::GzipReader.new(input)
|
78
|
+
v = gz.read
|
79
|
+
output.write(v)
|
80
|
+
unused = gz.unused
|
81
|
+
gz.finish
|
82
|
+
|
83
|
+
break if unused.nil?
|
84
|
+
adjust = unused.length
|
85
|
+
input.pos -= adjust
|
86
|
+
end
|
87
|
+
|
88
|
+
output
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#
|
2
|
+
# Fluentd
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'fluent/compat/exec_util'
|
18
|
+
|
19
|
+
module Fluent
|
20
|
+
# obsolete
|
21
|
+
ExecUtil = Fluent::Compat::ExecUtil
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#
|
2
|
+
# Fluentd
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'fluent/compat/file_util'
|
18
|
+
|
19
|
+
module Fluent
|
20
|
+
# obsolete
|
21
|
+
FileUtil = Fluent::Compat::FileUtil
|
22
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
#
|
2
|
+
# Fluentd
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
module Fluent
|
18
|
+
module FileWrapper
|
19
|
+
def self.open(*args)
|
20
|
+
io = WindowsFile.new(*args).io
|
21
|
+
if block_given?
|
22
|
+
v = yield io
|
23
|
+
io.close
|
24
|
+
v
|
25
|
+
else
|
26
|
+
io
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.stat(path)
|
31
|
+
f = WindowsFile.new(path)
|
32
|
+
s = f.stat
|
33
|
+
f.close
|
34
|
+
s
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
module WindowsFileExtension
|
39
|
+
attr_reader :path
|
40
|
+
|
41
|
+
def stat
|
42
|
+
s = super
|
43
|
+
s.instance_variable_set :@ino, @ino
|
44
|
+
def s.ino; @ino; end
|
45
|
+
s
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# To open and get stat with setting FILE_SHARE_DELETE
|
50
|
+
class WindowsFile
|
51
|
+
require 'windows/file'
|
52
|
+
require 'windows/error'
|
53
|
+
require 'windows/handle'
|
54
|
+
require 'windows/nio'
|
55
|
+
|
56
|
+
include Windows::Error
|
57
|
+
include Windows::File
|
58
|
+
include Windows::Handle
|
59
|
+
include Windows::NIO
|
60
|
+
|
61
|
+
def initialize(path, mode='r', sharemode=FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE)
|
62
|
+
@path = path
|
63
|
+
@file_handle = INVALID_HANDLE_VALUE
|
64
|
+
@mode = mode
|
65
|
+
|
66
|
+
|
67
|
+
access, creationdisposition, seektoend = case mode.delete('b')
|
68
|
+
when "r" ; [FILE_GENERIC_READ , OPEN_EXISTING, false]
|
69
|
+
when "r+"; [FILE_GENERIC_READ | FILE_GENERIC_WRITE, OPEN_ALWAYS , false]
|
70
|
+
when "w" ; [FILE_GENERIC_WRITE , CREATE_ALWAYS, false]
|
71
|
+
when "w+"; [FILE_GENERIC_READ | FILE_GENERIC_WRITE, CREATE_ALWAYS, false]
|
72
|
+
when "a" ; [FILE_GENERIC_WRITE , OPEN_ALWAYS , true]
|
73
|
+
when "a+"; [FILE_GENERIC_READ | FILE_GENERIC_WRITE, OPEN_ALWAYS , true]
|
74
|
+
else raise "unknown mode '#{mode}'"
|
75
|
+
end
|
76
|
+
|
77
|
+
@file_handle = CreateFile.call(@path, access, sharemode,
|
78
|
+
0, creationdisposition, FILE_ATTRIBUTE_NORMAL, 0)
|
79
|
+
if @file_handle == INVALID_HANDLE_VALUE
|
80
|
+
err = GetLastError.call
|
81
|
+
if err == ERROR_FILE_NOT_FOUND || err == ERROR_PATH_NOT_FOUND || err == ERROR_ACCESS_DENIED
|
82
|
+
raise SystemCallError.new(2)
|
83
|
+
end
|
84
|
+
raise SystemCallError.new(err)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def close
|
89
|
+
CloseHandle.call(@file_handle)
|
90
|
+
@file_handle = INVALID_HANDLE_VALUE
|
91
|
+
end
|
92
|
+
|
93
|
+
def io
|
94
|
+
fd = _open_osfhandle(@file_handle, 0)
|
95
|
+
raise Errno::ENOENT if fd == -1
|
96
|
+
io = File.for_fd(fd, @mode)
|
97
|
+
io.instance_variable_set :@ino, self.ino
|
98
|
+
io.instance_variable_set :@path, @path
|
99
|
+
io.extend WindowsFileExtension
|
100
|
+
io
|
101
|
+
end
|
102
|
+
|
103
|
+
def ino
|
104
|
+
by_handle_file_information = '\0'*(4+8+8+8+4+4+4+4+4+4) #72bytes
|
105
|
+
|
106
|
+
unless GetFileInformationByHandle.call(@file_handle, by_handle_file_information)
|
107
|
+
return 0
|
108
|
+
end
|
109
|
+
|
110
|
+
by_handle_file_information.unpack("I11Q1")[11] # fileindex
|
111
|
+
end
|
112
|
+
|
113
|
+
def stat
|
114
|
+
s = File.stat(@path)
|
115
|
+
s.instance_variable_set :@ino, self.ino
|
116
|
+
def s.ino; @ino; end
|
117
|
+
s
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end if Fluent.windows?
|
@@ -0,0 +1,93 @@
|
|
1
|
+
#
|
2
|
+
# Fluentd
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'fluent/plugin/base'
|
18
|
+
|
19
|
+
require 'fluent/event'
|
20
|
+
require 'fluent/log'
|
21
|
+
require 'fluent/plugin_id'
|
22
|
+
require 'fluent/plugin_helper'
|
23
|
+
|
24
|
+
module Fluent
|
25
|
+
module Plugin
|
26
|
+
class Filter < Base
|
27
|
+
include PluginId
|
28
|
+
include PluginLoggerMixin
|
29
|
+
include PluginHelper::Mixin
|
30
|
+
|
31
|
+
helpers_internal :event_emitter
|
32
|
+
|
33
|
+
attr_reader :has_filter_with_time
|
34
|
+
|
35
|
+
def initialize
|
36
|
+
super
|
37
|
+
@has_filter_with_time = has_filter_with_time?
|
38
|
+
end
|
39
|
+
|
40
|
+
def filter(tag, time, record)
|
41
|
+
raise NotImplementedError, "BUG: filter plugins MUST implement this method"
|
42
|
+
end
|
43
|
+
|
44
|
+
def filter_with_time(tag, time, record)
|
45
|
+
raise NotImplementedError, "BUG: filter plugins MUST implement this method"
|
46
|
+
end
|
47
|
+
|
48
|
+
def filter_stream(tag, es)
|
49
|
+
new_es = MultiEventStream.new
|
50
|
+
if @has_filter_with_time
|
51
|
+
es.each do |time, record|
|
52
|
+
begin
|
53
|
+
filtered_time, filtered_record = filter_with_time(tag, time, record)
|
54
|
+
new_es.add(filtered_time, filtered_record) if filtered_time && filtered_record
|
55
|
+
rescue => e
|
56
|
+
router.emit_error_event(tag, time, record, e)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
else
|
60
|
+
es.each do |time, record|
|
61
|
+
begin
|
62
|
+
filtered_record = filter(tag, time, record)
|
63
|
+
new_es.add(time, filtered_record) if filtered_record
|
64
|
+
rescue => e
|
65
|
+
router.emit_error_event(tag, time, record, e)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
new_es
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
def has_filter_with_time?
|
75
|
+
implmented_methods = self.class.instance_methods(false)
|
76
|
+
# Plugins that override `filter_stream` don't need check,
|
77
|
+
# because they may not call `filter` or `filter_with_time`
|
78
|
+
# for example fluentd/lib/fluent/plugin/filter_record_transformer.rb
|
79
|
+
return nil if implmented_methods.include?(:filter_stream)
|
80
|
+
case
|
81
|
+
when [:filter, :filter_with_time].all? { |e| implmented_methods.include?(e) }
|
82
|
+
raise "BUG: Filter plugins MUST be implemented either `filter` or `filter_with_time`"
|
83
|
+
when implmented_methods.include?(:filter)
|
84
|
+
false
|
85
|
+
when implmented_methods.include?(:filter_with_time)
|
86
|
+
true
|
87
|
+
else
|
88
|
+
raise NotImplementedError, "BUG: Filter plugins MUST be implmented either `filter` or `filter_with_time`"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
#
|
2
|
+
# Fluentd
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
require 'fluent/plugin/filter'
|
18
|
+
require 'fluent/config/error'
|
19
|
+
require 'fluent/plugin/string_util'
|
20
|
+
|
21
|
+
module Fluent::Plugin
|
22
|
+
class GrepFilter < Filter
|
23
|
+
Fluent::Plugin.register_filter('grep', self)
|
24
|
+
|
25
|
+
REGEXP_MAX_NUM = 20
|
26
|
+
|
27
|
+
(1..REGEXP_MAX_NUM).each {|i| config_param :"regexp#{i}", :string, default: nil }
|
28
|
+
(1..REGEXP_MAX_NUM).each {|i| config_param :"exclude#{i}", :string, default: nil }
|
29
|
+
|
30
|
+
# for test
|
31
|
+
attr_reader :regexps
|
32
|
+
attr_reader :excludes
|
33
|
+
|
34
|
+
def configure(conf)
|
35
|
+
super
|
36
|
+
|
37
|
+
@regexps = {}
|
38
|
+
(1..REGEXP_MAX_NUM).each do |i|
|
39
|
+
next unless conf["regexp#{i}"]
|
40
|
+
key, regexp = conf["regexp#{i}"].split(/ /, 2)
|
41
|
+
raise Fluent::ConfigError, "regexp#{i} does not contain 2 parameters" unless regexp
|
42
|
+
raise Fluent::ConfigError, "regexp#{i} contains a duplicated key, #{key}" if @regexps[key]
|
43
|
+
@regexps[key] = Regexp.compile(regexp)
|
44
|
+
end
|
45
|
+
|
46
|
+
@excludes = {}
|
47
|
+
(1..REGEXP_MAX_NUM).each do |i|
|
48
|
+
next unless conf["exclude#{i}"]
|
49
|
+
key, exclude = conf["exclude#{i}"].split(/ /, 2)
|
50
|
+
raise Fluent::ConfigError, "exclude#{i} does not contain 2 parameters" unless exclude
|
51
|
+
raise Fluent::ConfigError, "exclude#{i} contains a duplicated key, #{key}" if @excludes[key]
|
52
|
+
@excludes[key] = Regexp.compile(exclude)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def filter(tag, time, record)
|
57
|
+
result = nil
|
58
|
+
begin
|
59
|
+
catch(:break_loop) do
|
60
|
+
@regexps.each do |key, regexp|
|
61
|
+
throw :break_loop unless ::Fluent::StringUtil.match_regexp(regexp, record[key].to_s)
|
62
|
+
end
|
63
|
+
@excludes.each do |key, exclude|
|
64
|
+
throw :break_loop if ::Fluent::StringUtil.match_regexp(exclude, record[key].to_s)
|
65
|
+
end
|
66
|
+
result = record
|
67
|
+
end
|
68
|
+
rescue => e
|
69
|
+
log.warn "failed to grep events", error: e
|
70
|
+
log.warn_backtrace
|
71
|
+
end
|
72
|
+
result
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|