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,448 @@
|
|
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 'json'
|
18
|
+
require 'webrick'
|
19
|
+
require 'cgi'
|
20
|
+
|
21
|
+
require 'fluent/config/types'
|
22
|
+
require 'fluent/plugin/input'
|
23
|
+
require 'fluent/plugin/output'
|
24
|
+
require 'fluent/plugin/multi_output'
|
25
|
+
require 'fluent/plugin/filter'
|
26
|
+
|
27
|
+
module Fluent::Plugin
|
28
|
+
class MonitorAgentInput < Input
|
29
|
+
Fluent::Plugin.register_input('monitor_agent', self)
|
30
|
+
|
31
|
+
helpers :timer, :thread
|
32
|
+
|
33
|
+
config_param :bind, :string, default: '0.0.0.0'
|
34
|
+
config_param :port, :integer, default: 24220
|
35
|
+
config_param :tag, :string, default: nil
|
36
|
+
config_param :emit_interval, :time, default: 60
|
37
|
+
config_param :include_config, :bool, default: true
|
38
|
+
config_param :include_retry, :bool, default: true
|
39
|
+
|
40
|
+
class MonitorServlet < WEBrick::HTTPServlet::AbstractServlet
|
41
|
+
def initialize(server, agent)
|
42
|
+
@agent = agent
|
43
|
+
end
|
44
|
+
|
45
|
+
def do_GET(req, res)
|
46
|
+
begin
|
47
|
+
code, header, body = process(req, res)
|
48
|
+
rescue
|
49
|
+
code, header, body = render_json_error(500, {
|
50
|
+
'message '=> 'Internal Server Error',
|
51
|
+
'error' => "#{$!}",
|
52
|
+
'backgrace'=> $!.backtrace,
|
53
|
+
})
|
54
|
+
end
|
55
|
+
|
56
|
+
# set response code, header and body
|
57
|
+
res.status = code
|
58
|
+
header.each_pair {|k,v|
|
59
|
+
res[k] = v
|
60
|
+
}
|
61
|
+
res.body = body
|
62
|
+
end
|
63
|
+
|
64
|
+
def build_object(req, res)
|
65
|
+
unless req.path_info == ""
|
66
|
+
return render_json_error(404, "Not found")
|
67
|
+
end
|
68
|
+
|
69
|
+
# parse ?=query string
|
70
|
+
if req.query_string
|
71
|
+
begin
|
72
|
+
qs = CGI.parse(req.query_string)
|
73
|
+
rescue
|
74
|
+
return render_json_error(400, "Invalid query string")
|
75
|
+
end
|
76
|
+
else
|
77
|
+
qs = Hash.new {|h,k| [] }
|
78
|
+
end
|
79
|
+
|
80
|
+
# if ?debug=1 is set, set :with_debug_info for get_monitor_info
|
81
|
+
# and :pretty_json for render_json_error
|
82
|
+
opts = {with_config: @agent.include_config, with_retry: @agent.include_retry}
|
83
|
+
if s = qs['debug'] and s[0]
|
84
|
+
opts[:with_debug_info] = true
|
85
|
+
opts[:pretty_json] = true
|
86
|
+
end
|
87
|
+
|
88
|
+
if ivars = (qs['with_ivars'] || []).first
|
89
|
+
opts[:ivars] = ivars.split(',')
|
90
|
+
end
|
91
|
+
|
92
|
+
if with_config = get_search_parameter(qs, 'with_config'.freeze)
|
93
|
+
opts[:with_config] = Fluent::Config.bool_value(with_config)
|
94
|
+
end
|
95
|
+
|
96
|
+
if with_retry = get_search_parameter(qs, 'with_retry'.freeze)
|
97
|
+
opts[:with_retry] = Fluent::Config.bool_value(with_retry)
|
98
|
+
end
|
99
|
+
|
100
|
+
if tag = get_search_parameter(qs, 'tag'.freeze)
|
101
|
+
# ?tag= to search an output plugin by match pattern
|
102
|
+
if obj = @agent.plugin_info_by_tag(tag, opts)
|
103
|
+
list = [obj]
|
104
|
+
else
|
105
|
+
list = []
|
106
|
+
end
|
107
|
+
|
108
|
+
elsif plugin_id = get_search_parameter(qs, '@id'.freeze)
|
109
|
+
# ?@id= to search a plugin by 'id <plugin_id>' config param
|
110
|
+
if obj = @agent.plugin_info_by_id(plugin_id, opts)
|
111
|
+
list = [obj]
|
112
|
+
else
|
113
|
+
list = []
|
114
|
+
end
|
115
|
+
|
116
|
+
elsif plugin_id = get_search_parameter(qs, 'id'.freeze)
|
117
|
+
# Without @ version of ?@id= for backward compatibility
|
118
|
+
if obj = @agent.plugin_info_by_id(plugin_id, opts)
|
119
|
+
list = [obj]
|
120
|
+
else
|
121
|
+
list = []
|
122
|
+
end
|
123
|
+
|
124
|
+
elsif plugin_type = get_search_parameter(qs, '@type'.freeze)
|
125
|
+
# ?@type= to search plugins by 'type <type>' config param
|
126
|
+
list = @agent.plugins_info_by_type(plugin_type, opts)
|
127
|
+
|
128
|
+
elsif plugin_type = get_search_parameter(qs, 'type'.freeze)
|
129
|
+
# Without @ version of ?@type= for backward compatibility
|
130
|
+
list = @agent.plugins_info_by_type(plugin_type, opts)
|
131
|
+
|
132
|
+
else
|
133
|
+
# otherwise show all plugins
|
134
|
+
list = @agent.plugins_info_all(opts)
|
135
|
+
end
|
136
|
+
|
137
|
+
return list, opts
|
138
|
+
end
|
139
|
+
|
140
|
+
def get_search_parameter(qs, param_name)
|
141
|
+
return nil unless qs.has_key?(param_name)
|
142
|
+
qs[param_name].first
|
143
|
+
end
|
144
|
+
|
145
|
+
def render_json(obj, opts={})
|
146
|
+
render_json_error(200, obj, opts)
|
147
|
+
end
|
148
|
+
|
149
|
+
def render_json_error(code, obj, opts={})
|
150
|
+
if opts[:pretty_json]
|
151
|
+
js = JSON.pretty_generate(obj)
|
152
|
+
else
|
153
|
+
js = obj.to_json
|
154
|
+
end
|
155
|
+
[code, {'Content-Type'=>'application/json'}, js]
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
class LTSVMonitorServlet < MonitorServlet
|
160
|
+
def process(req, res)
|
161
|
+
list, _opts = build_object(req, res)
|
162
|
+
return unless list
|
163
|
+
|
164
|
+
normalized = JSON.parse(list.to_json)
|
165
|
+
|
166
|
+
text = ''
|
167
|
+
|
168
|
+
normalized.map {|hash|
|
169
|
+
row = []
|
170
|
+
hash.each_pair {|k,v|
|
171
|
+
unless v.is_a?(Hash) || v.is_a?(Array)
|
172
|
+
row << "#{k}:#{v}"
|
173
|
+
end
|
174
|
+
}
|
175
|
+
text << row.join("\t") << "\n"
|
176
|
+
}
|
177
|
+
|
178
|
+
[200, {'Content-Type'=>'text/plain'}, text]
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
class JSONMonitorServlet < MonitorServlet
|
183
|
+
def process(req, res)
|
184
|
+
list, opts = build_object(req, res)
|
185
|
+
return unless list
|
186
|
+
|
187
|
+
render_json({
|
188
|
+
'plugins' => list
|
189
|
+
}, opts)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
class ConfigMonitorServlet < MonitorServlet
|
194
|
+
def build_object(req, res)
|
195
|
+
{
|
196
|
+
'pid' => Process.pid,
|
197
|
+
'ppid' => Process.ppid
|
198
|
+
}.merge(@agent.fluentd_opts)
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
class LTSVConfigMonitorServlet < ConfigMonitorServlet
|
203
|
+
def process(req, res)
|
204
|
+
result = build_object(req, res)
|
205
|
+
|
206
|
+
row = []
|
207
|
+
JSON.parse(result.to_json).each_pair { |k, v|
|
208
|
+
row << "#{k}:#{v}"
|
209
|
+
}
|
210
|
+
text = row.join("\t")
|
211
|
+
|
212
|
+
[200, {'Content-Type'=>'text/plain'}, text]
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
class JSONConfigMonitorServlet < ConfigMonitorServlet
|
217
|
+
def process(req, res)
|
218
|
+
result = build_object(req, res)
|
219
|
+
render_json(result)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
def initialize
|
224
|
+
super
|
225
|
+
|
226
|
+
@first_warn = false
|
227
|
+
end
|
228
|
+
|
229
|
+
def configure(conf)
|
230
|
+
super
|
231
|
+
@port += fluentd_worker_id
|
232
|
+
end
|
233
|
+
|
234
|
+
def multi_workers_ready?
|
235
|
+
true
|
236
|
+
end
|
237
|
+
|
238
|
+
def start
|
239
|
+
super
|
240
|
+
|
241
|
+
log.debug "listening monitoring http server on http://#{@bind}:#{@port}/api/plugins for worker#{fluentd_worker_id}"
|
242
|
+
@srv = WEBrick::HTTPServer.new({
|
243
|
+
BindAddress: @bind,
|
244
|
+
Port: @port,
|
245
|
+
Logger: WEBrick::Log.new(STDERR, WEBrick::Log::FATAL),
|
246
|
+
AccessLog: [],
|
247
|
+
})
|
248
|
+
@srv.mount('/api/plugins', LTSVMonitorServlet, self)
|
249
|
+
@srv.mount('/api/plugins.json', JSONMonitorServlet, self)
|
250
|
+
@srv.mount('/api/config', LTSVConfigMonitorServlet, self)
|
251
|
+
@srv.mount('/api/config.json', JSONConfigMonitorServlet, self)
|
252
|
+
thread_create :in_monitor_agent_servlet do
|
253
|
+
@srv.start
|
254
|
+
end
|
255
|
+
if @tag
|
256
|
+
log.debug "tag parameter is specified. Emit plugins info to '#{@tag}'"
|
257
|
+
|
258
|
+
opts = {with_config: false, with_retry: false}
|
259
|
+
timer_execute(:in_monitor_agent_emit, @emit_interval, repeat: true) {
|
260
|
+
es = Fluent::MultiEventStream.new
|
261
|
+
now = Fluent::Engine.now
|
262
|
+
plugins_info_all(opts).each { |record|
|
263
|
+
es.add(now, record)
|
264
|
+
}
|
265
|
+
router.emit_stream(@tag, es)
|
266
|
+
}
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
def shutdown
|
271
|
+
if @srv
|
272
|
+
@srv.shutdown
|
273
|
+
@srv = nil
|
274
|
+
end
|
275
|
+
|
276
|
+
super
|
277
|
+
end
|
278
|
+
|
279
|
+
MONITOR_INFO = {
|
280
|
+
'output_plugin' => ->(){ is_a?(::Fluent::Plugin::Output) },
|
281
|
+
'buffer_queue_length' => ->(){ throw(:skip) unless instance_variable_defined?(:@buffer) && !@buffer.nil?; @buffer.queue.size },
|
282
|
+
'buffer_total_queued_size' => ->(){ throw(:skip) unless instance_variable_defined?(:@buffer) && !@buffer.nil?; @buffer.stage_size },
|
283
|
+
'retry_count' => ->(){ instance_variable_defined?(:@num_errors) ? @num_errors : nil },
|
284
|
+
}
|
285
|
+
|
286
|
+
def all_plugins
|
287
|
+
array = []
|
288
|
+
|
289
|
+
# get all input plugins
|
290
|
+
array.concat Fluent::Engine.root_agent.inputs
|
291
|
+
|
292
|
+
# get all output plugins
|
293
|
+
array.concat Fluent::Engine.root_agent.outputs
|
294
|
+
|
295
|
+
# get all filter plugins
|
296
|
+
array.concat Fluent::Engine.root_agent.filters
|
297
|
+
|
298
|
+
Fluent::Engine.root_agent.labels.each { |name, l|
|
299
|
+
# TODO: Add label name to outputs / filters for identifing plugins
|
300
|
+
array.concat l.outputs
|
301
|
+
array.concat l.filters
|
302
|
+
}
|
303
|
+
|
304
|
+
array
|
305
|
+
end
|
306
|
+
|
307
|
+
# try to match the tag and get the info from the matched output plugin
|
308
|
+
# TODO: Support output in label
|
309
|
+
def plugin_info_by_tag(tag, opts={})
|
310
|
+
matches = Fluent::Engine.root_agent.event_router.instance_variable_get(:@match_rules)
|
311
|
+
matches.each { |rule|
|
312
|
+
if rule.match?(tag)
|
313
|
+
if rule.collector.is_a?(Fluent::Plugin::Output) || rule.collector.is_a?(Fluent::Output)
|
314
|
+
return get_monitor_info(rule.collector, opts)
|
315
|
+
end
|
316
|
+
end
|
317
|
+
}
|
318
|
+
nil
|
319
|
+
end
|
320
|
+
|
321
|
+
# search a plugin by plugin_id
|
322
|
+
def plugin_info_by_id(plugin_id, opts={})
|
323
|
+
found = all_plugins.find {|pe|
|
324
|
+
pe.respond_to?(:plugin_id) && pe.plugin_id.to_s == plugin_id
|
325
|
+
}
|
326
|
+
if found
|
327
|
+
get_monitor_info(found, opts)
|
328
|
+
else
|
329
|
+
nil
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
# This method returns an array because
|
334
|
+
# multiple plugins could have the same type
|
335
|
+
def plugins_info_by_type(type, opts={})
|
336
|
+
array = all_plugins.select {|pe|
|
337
|
+
(pe.config['@type'] == type) rescue nil
|
338
|
+
}
|
339
|
+
array.map {|pe|
|
340
|
+
get_monitor_info(pe, opts)
|
341
|
+
}
|
342
|
+
end
|
343
|
+
|
344
|
+
def plugins_info_all(opts={})
|
345
|
+
all_plugins.map {|pe|
|
346
|
+
get_monitor_info(pe, opts)
|
347
|
+
}
|
348
|
+
end
|
349
|
+
|
350
|
+
IGNORE_ATTRIBUTES = %i(@config_root_section @config @masked_config)
|
351
|
+
|
352
|
+
# get monitor info from the plugin `pe` and return a hash object
|
353
|
+
def get_monitor_info(pe, opts={})
|
354
|
+
obj = {}
|
355
|
+
|
356
|
+
# Common plugin information
|
357
|
+
obj['plugin_id'] = pe.plugin_id
|
358
|
+
obj['plugin_category'] = plugin_category(pe)
|
359
|
+
obj['type'] = pe.config['@type']
|
360
|
+
obj['config'] = pe.config if opts[:with_config]
|
361
|
+
|
362
|
+
# run MONITOR_INFO in plugins' instance context and store the info to obj
|
363
|
+
MONITOR_INFO.each_pair {|key,code|
|
364
|
+
begin
|
365
|
+
catch(:skip) do
|
366
|
+
obj[key] = pe.instance_exec(&code)
|
367
|
+
end
|
368
|
+
rescue NoMethodError => e
|
369
|
+
unless @first_warn
|
370
|
+
log.error "NoMethodError in monitoring plugins", key: key, plugin: pe.class, error: e
|
371
|
+
log.error_backtrace
|
372
|
+
@first_warn = true
|
373
|
+
end
|
374
|
+
rescue => e
|
375
|
+
log.warn "unexpected error in monitoring plugins", key: key, plugin: pe.class, error: e
|
376
|
+
end
|
377
|
+
}
|
378
|
+
|
379
|
+
obj['retry'] = get_retry_info(pe.retry) if opts[:with_retry] and pe.instance_variable_defined?(:@retry)
|
380
|
+
|
381
|
+
# include all instance variables if :with_debug_info is set
|
382
|
+
if opts[:with_debug_info]
|
383
|
+
iv = {}
|
384
|
+
pe.instance_eval do
|
385
|
+
instance_variables.each {|sym|
|
386
|
+
next if IGNORE_ATTRIBUTES.include?(sym)
|
387
|
+
key = sym.to_s[1..-1] # removes first '@'
|
388
|
+
iv[key] = instance_variable_get(sym)
|
389
|
+
}
|
390
|
+
end
|
391
|
+
obj['instance_variables'] = iv
|
392
|
+
elsif ivars = opts[:ivars]
|
393
|
+
iv = {}
|
394
|
+
ivars.each {|name|
|
395
|
+
iname = "@#{name}"
|
396
|
+
iv[name] = pe.instance_variable_get(iname) if pe.instance_variable_defined?(iname)
|
397
|
+
}
|
398
|
+
obj['instance_variables'] = iv
|
399
|
+
end
|
400
|
+
|
401
|
+
obj
|
402
|
+
end
|
403
|
+
|
404
|
+
RETRY_INFO = {
|
405
|
+
'start' => '@start',
|
406
|
+
'steps' => '@steps',
|
407
|
+
'next_time' => '@next_time',
|
408
|
+
}
|
409
|
+
|
410
|
+
def get_retry_info(pe_retry)
|
411
|
+
retry_variables = {}
|
412
|
+
|
413
|
+
if pe_retry
|
414
|
+
RETRY_INFO.each_pair { |key, param|
|
415
|
+
retry_variables[key] = pe_retry.instance_variable_get(param)
|
416
|
+
}
|
417
|
+
end
|
418
|
+
|
419
|
+
retry_variables
|
420
|
+
end
|
421
|
+
|
422
|
+
def plugin_category(pe)
|
423
|
+
case pe
|
424
|
+
when Fluent::Plugin::Input
|
425
|
+
'input'.freeze
|
426
|
+
when Fluent::Plugin::Output, Fluent::Plugin::MultiOutput, Fluent::Plugin::BareOutput
|
427
|
+
'output'.freeze
|
428
|
+
when Fluent::Plugin::Filter
|
429
|
+
'filter'.freeze
|
430
|
+
else
|
431
|
+
'unknown'.freeze
|
432
|
+
end
|
433
|
+
end
|
434
|
+
|
435
|
+
def fluentd_opts
|
436
|
+
@fluentd_opts ||= get_fluentd_opts
|
437
|
+
end
|
438
|
+
|
439
|
+
def get_fluentd_opts
|
440
|
+
opts = {}
|
441
|
+
ObjectSpace.each_object(Fluent::Supervisor) { |obj|
|
442
|
+
opts.merge!(obj.options)
|
443
|
+
break
|
444
|
+
}
|
445
|
+
opts
|
446
|
+
end
|
447
|
+
end
|
448
|
+
end
|
@@ -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 'yajl'
|
18
|
+
|
19
|
+
require 'fluent/plugin/input'
|
20
|
+
|
21
|
+
module Fluent::Plugin
|
22
|
+
class ObjectSpaceInput < Fluent::Plugin::Input
|
23
|
+
Fluent::Plugin.register_input('object_space', self)
|
24
|
+
|
25
|
+
helpers :timer
|
26
|
+
|
27
|
+
def initialize
|
28
|
+
super
|
29
|
+
end
|
30
|
+
|
31
|
+
config_param :emit_interval, :time, default: 60
|
32
|
+
config_param :tag, :string
|
33
|
+
config_param :top, :integer, default: 15
|
34
|
+
|
35
|
+
def multi_workers_ready?
|
36
|
+
true
|
37
|
+
end
|
38
|
+
|
39
|
+
def start
|
40
|
+
super
|
41
|
+
|
42
|
+
timer_execute(:object_space_input, @emit_interval, &method(:on_timer))
|
43
|
+
end
|
44
|
+
|
45
|
+
class Counter
|
46
|
+
def initialize(klass, init_count)
|
47
|
+
@klass = klass
|
48
|
+
@count = init_count
|
49
|
+
end
|
50
|
+
|
51
|
+
def incr!
|
52
|
+
@count += 1
|
53
|
+
end
|
54
|
+
|
55
|
+
def name
|
56
|
+
@klass.name
|
57
|
+
end
|
58
|
+
|
59
|
+
attr_reader :count
|
60
|
+
end
|
61
|
+
|
62
|
+
def on_timer
|
63
|
+
now = Fluent::EventTime.now
|
64
|
+
|
65
|
+
array = []
|
66
|
+
map = {}
|
67
|
+
|
68
|
+
ObjectSpace.each_object {|obj|
|
69
|
+
klass = obj.class rescue Object
|
70
|
+
if c = map[klass]
|
71
|
+
c.incr!
|
72
|
+
else
|
73
|
+
c = Counter.new(klass, 1)
|
74
|
+
array << c
|
75
|
+
map[klass] = c
|
76
|
+
end
|
77
|
+
}
|
78
|
+
|
79
|
+
array.sort_by! {|c| -c.count }
|
80
|
+
|
81
|
+
record = {}
|
82
|
+
array.each_with_index {|c,i|
|
83
|
+
break if i >= @top
|
84
|
+
record[c.name] = c.count
|
85
|
+
}
|
86
|
+
|
87
|
+
router.emit(@tag, now, record)
|
88
|
+
rescue => e
|
89
|
+
log.error "object space failed to emit", error: e, tag: @tag, record: Yajl.dump(record)
|
90
|
+
log.error_backtrace
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|