fluentd 1.20.0-aarch64-mingw-ucrt
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rubocop.yml +116 -0
- data/ADOPTERS.md +5 -0
- data/AGENTS.md +46 -0
- data/AUTHORS +2 -0
- data/CHANGELOG.md +3324 -0
- data/CONTRIBUTING.md +45 -0
- data/GOVERNANCE.md +55 -0
- data/GithubWorkflow.md +78 -0
- data/LICENSE +202 -0
- data/MAINTAINERS.md +19 -0
- data/README.md +73 -0
- data/Rakefile +89 -0
- data/SECURITY.md +47 -0
- data/bin/fluent-binlog-reader +7 -0
- data/bin/fluent-ca-generate +6 -0
- data/bin/fluent-cap-ctl +7 -0
- data/bin/fluent-cat +5 -0
- data/bin/fluent-ctl +7 -0
- data/bin/fluent-debug +5 -0
- data/bin/fluent-gem +9 -0
- data/bin/fluent-plugin-config-format +5 -0
- data/bin/fluent-plugin-generate +5 -0
- data/bin/fluentd +15 -0
- data/code-of-conduct.md +3 -0
- data/docs/SECURITY_AUDIT.pdf +0 -0
- data/example/copy_roundrobin.conf +39 -0
- data/example/counter.conf +18 -0
- data/example/filter_stdout.conf +22 -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 +16 -0
- data/example/in_out_forward.conf +17 -0
- data/example/in_sample_blocks.conf +17 -0
- data/example/in_sample_with_compression.conf +23 -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_sd.conf +17 -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/sd.yaml +8 -0
- data/example/secondary_file.conf +42 -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/example/worker_section.conf +36 -0
- data/fluent.conf +139 -0
- data/lib/fluent/agent.rb +168 -0
- data/lib/fluent/capability.rb +87 -0
- data/lib/fluent/clock.rb +66 -0
- data/lib/fluent/command/binlog_reader.rb +244 -0
- data/lib/fluent/command/bundler_injection.rb +45 -0
- data/lib/fluent/command/ca_generate.rb +184 -0
- data/lib/fluent/command/cap_ctl.rb +174 -0
- data/lib/fluent/command/cat.rb +365 -0
- data/lib/fluent/command/ctl.rb +180 -0
- data/lib/fluent/command/debug.rb +103 -0
- data/lib/fluent/command/fluentd.rb +385 -0
- data/lib/fluent/command/plugin_config_formatter.rb +308 -0
- data/lib/fluent/command/plugin_generator.rb +365 -0
- data/lib/fluent/compat/call_super_mixin.rb +76 -0
- data/lib/fluent/compat/detach_process_mixin.rb +33 -0
- data/lib/fluent/compat/exec_util.rb +144 -0
- data/lib/fluent/compat/file_util.rb +54 -0
- data/lib/fluent/compat/filter.rb +68 -0
- data/lib/fluent/compat/formatter.rb +117 -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 +49 -0
- data/lib/fluent/compat/output.rb +721 -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/basic_parser.rb +122 -0
- data/lib/fluent/config/configure_proxy.rb +424 -0
- data/lib/fluent/config/dsl.rb +152 -0
- data/lib/fluent/config/element.rb +265 -0
- data/lib/fluent/config/error.rb +44 -0
- data/lib/fluent/config/literal_parser.rb +305 -0
- data/lib/fluent/config/parser.rb +119 -0
- data/lib/fluent/config/section.rb +272 -0
- data/lib/fluent/config/types.rb +257 -0
- data/lib/fluent/config/v1_parser.rb +200 -0
- data/lib/fluent/config/yaml_parser/fluent_value.rb +47 -0
- data/lib/fluent/config/yaml_parser/loader.rb +124 -0
- data/lib/fluent/config/yaml_parser/parser.rb +179 -0
- data/lib/fluent/config/yaml_parser/section_builder.rb +107 -0
- data/lib/fluent/config/yaml_parser.rb +56 -0
- data/lib/fluent/config.rb +89 -0
- data/lib/fluent/configurable.rb +202 -0
- data/lib/fluent/counter/base_socket.rb +44 -0
- data/lib/fluent/counter/client.rb +297 -0
- data/lib/fluent/counter/error.rb +86 -0
- data/lib/fluent/counter/mutex_hash.rb +163 -0
- data/lib/fluent/counter/server.rb +273 -0
- data/lib/fluent/counter/store.rb +205 -0
- data/lib/fluent/counter/validator.rb +145 -0
- data/lib/fluent/counter.rb +23 -0
- data/lib/fluent/daemon.rb +14 -0
- data/lib/fluent/daemonizer.rb +88 -0
- data/lib/fluent/engine.rb +269 -0
- data/lib/fluent/env.rb +45 -0
- data/lib/fluent/error.rb +37 -0
- data/lib/fluent/event.rb +369 -0
- data/lib/fluent/event_router.rb +315 -0
- data/lib/fluent/ext_monitor_require.rb +28 -0
- data/lib/fluent/file_wrapper.rb +137 -0
- data/lib/fluent/filter.rb +21 -0
- data/lib/fluent/fluent_log_event_router.rb +139 -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 +33 -0
- data/lib/fluent/log/console_adapter.rb +66 -0
- data/lib/fluent/log.rb +775 -0
- data/lib/fluent/match.rb +187 -0
- data/lib/fluent/mixin.rb +31 -0
- data/lib/fluent/msgpack_factory.rb +111 -0
- data/lib/fluent/oj_options.rb +61 -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/bare_output.rb +88 -0
- data/lib/fluent/plugin/base.rb +219 -0
- data/lib/fluent/plugin/buf_file.rb +256 -0
- data/lib/fluent/plugin/buf_file_single.rb +272 -0
- data/lib/fluent/plugin/buf_memory.rb +34 -0
- data/lib/fluent/plugin/buffer/chunk.rb +313 -0
- data/lib/fluent/plugin/buffer/file_chunk.rb +432 -0
- data/lib/fluent/plugin/buffer/file_single_chunk.rb +325 -0
- data/lib/fluent/plugin/buffer/memory_chunk.rb +91 -0
- data/lib/fluent/plugin/buffer.rb +1063 -0
- data/lib/fluent/plugin/compressable.rb +87 -0
- data/lib/fluent/plugin/exec_util.rb +22 -0
- data/lib/fluent/plugin/extractor.rb +132 -0
- data/lib/fluent/plugin/file_util.rb +22 -0
- data/lib/fluent/plugin/filter.rb +119 -0
- data/lib/fluent/plugin/filter_grep.rb +189 -0
- data/lib/fluent/plugin/filter_parser.rb +124 -0
- data/lib/fluent/plugin/filter_record_transformer.rb +325 -0
- data/lib/fluent/plugin/filter_stdout.rb +53 -0
- data/lib/fluent/plugin/formatter.rb +75 -0
- data/lib/fluent/plugin/formatter_csv.rb +92 -0
- data/lib/fluent/plugin/formatter_hash.rb +35 -0
- data/lib/fluent/plugin/formatter_json.rb +62 -0
- data/lib/fluent/plugin/formatter_ltsv.rb +44 -0
- data/lib/fluent/plugin/formatter_msgpack.rb +33 -0
- data/lib/fluent/plugin/formatter_out_file.rb +55 -0
- data/lib/fluent/plugin/formatter_single_value.rb +36 -0
- data/lib/fluent/plugin/formatter_stdout.rb +76 -0
- data/lib/fluent/plugin/formatter_tsv.rb +40 -0
- data/lib/fluent/plugin/in_debug_agent.rb +71 -0
- data/lib/fluent/plugin/in_dummy.rb +18 -0
- data/lib/fluent/plugin/in_exec.rb +124 -0
- data/lib/fluent/plugin/in_forward.rb +489 -0
- data/lib/fluent/plugin/in_gc_stat.rb +72 -0
- data/lib/fluent/plugin/in_http.rb +737 -0
- data/lib/fluent/plugin/in_monitor_agent.rb +406 -0
- data/lib/fluent/plugin/in_object_space.rb +93 -0
- data/lib/fluent/plugin/in_sample.rb +148 -0
- data/lib/fluent/plugin/in_syslog.rb +346 -0
- data/lib/fluent/plugin/in_tail/compatibility.rb +111 -0
- data/lib/fluent/plugin/in_tail/dir_watcher.rb +713 -0
- data/lib/fluent/plugin/in_tail/group_watch.rb +204 -0
- data/lib/fluent/plugin/in_tail/io_handler.rb +391 -0
- data/lib/fluent/plugin/in_tail/line_feeder.rb +230 -0
- data/lib/fluent/plugin/in_tail/position_file.rb +269 -0
- data/lib/fluent/plugin/in_tail/stat_watcher.rb +52 -0
- data/lib/fluent/plugin/in_tail/tail_watcher.rb +276 -0
- data/lib/fluent/plugin/in_tail/worker_pool.rb +298 -0
- data/lib/fluent/plugin/in_tail.rb +917 -0
- data/lib/fluent/plugin/in_tcp.rb +230 -0
- data/lib/fluent/plugin/in_udp.rb +101 -0
- data/lib/fluent/plugin/in_unix.rb +197 -0
- data/lib/fluent/plugin/input.rb +71 -0
- data/lib/fluent/plugin/metrics.rb +119 -0
- data/lib/fluent/plugin/metrics_local.rb +96 -0
- data/lib/fluent/plugin/multi_output.rb +179 -0
- data/lib/fluent/plugin/out_buffer.rb +40 -0
- data/lib/fluent/plugin/out_copy.rb +120 -0
- data/lib/fluent/plugin/out_exec.rb +105 -0
- data/lib/fluent/plugin/out_exec_filter.rb +319 -0
- data/lib/fluent/plugin/out_file.rb +371 -0
- data/lib/fluent/plugin/out_forward/ack_handler.rb +176 -0
- data/lib/fluent/plugin/out_forward/connection_manager.rb +131 -0
- data/lib/fluent/plugin/out_forward/error.rb +28 -0
- data/lib/fluent/plugin/out_forward/failure_detector.rb +84 -0
- data/lib/fluent/plugin/out_forward/handshake_protocol.rb +125 -0
- data/lib/fluent/plugin/out_forward/load_balancer.rb +114 -0
- data/lib/fluent/plugin/out_forward/socket_cache.rb +177 -0
- data/lib/fluent/plugin/out_forward.rb +865 -0
- data/lib/fluent/plugin/out_http.rb +419 -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 +148 -0
- data/lib/fluent/plugin/out_stdout.rb +81 -0
- data/lib/fluent/plugin/out_stream.rb +130 -0
- data/lib/fluent/plugin/output.rb +1688 -0
- data/lib/fluent/plugin/owned_by_mixin.rb +41 -0
- data/lib/fluent/plugin/parser.rb +274 -0
- data/lib/fluent/plugin/parser_apache.rb +28 -0
- data/lib/fluent/plugin/parser_apache2.rb +88 -0
- data/lib/fluent/plugin/parser_apache_error.rb +26 -0
- data/lib/fluent/plugin/parser_csv.rb +124 -0
- data/lib/fluent/plugin/parser_json.rb +118 -0
- data/lib/fluent/plugin/parser_ltsv.rb +49 -0
- data/lib/fluent/plugin/parser_msgpack.rb +72 -0
- data/lib/fluent/plugin/parser_multiline.rb +152 -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 +68 -0
- data/lib/fluent/plugin/parser_syslog.rb +543 -0
- data/lib/fluent/plugin/parser_tsv.rb +47 -0
- data/lib/fluent/plugin/sd_file.rb +157 -0
- data/lib/fluent/plugin/sd_srv.rb +135 -0
- data/lib/fluent/plugin/sd_static.rb +58 -0
- data/lib/fluent/plugin/service_discovery.rb +65 -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 +166 -0
- data/lib/fluent/plugin/string_util.rb +22 -0
- data/lib/fluent/plugin.rb +206 -0
- data/lib/fluent/plugin_helper/cert_option.rb +199 -0
- data/lib/fluent/plugin_helper/child_process.rb +369 -0
- data/lib/fluent/plugin_helper/compat_parameters.rb +343 -0
- data/lib/fluent/plugin_helper/counter.rb +51 -0
- data/lib/fluent/plugin_helper/event_emitter.rb +112 -0
- data/lib/fluent/plugin_helper/event_loop.rb +170 -0
- data/lib/fluent/plugin_helper/extract.rb +104 -0
- data/lib/fluent/plugin_helper/formatter.rb +147 -0
- data/lib/fluent/plugin_helper/http_server/app.rb +81 -0
- data/lib/fluent/plugin_helper/http_server/methods.rb +35 -0
- data/lib/fluent/plugin_helper/http_server/request.rb +53 -0
- data/lib/fluent/plugin_helper/http_server/router.rb +54 -0
- data/lib/fluent/plugin_helper/http_server/server.rb +116 -0
- data/lib/fluent/plugin_helper/http_server/ssl_context_builder.rb +41 -0
- data/lib/fluent/plugin_helper/http_server.rb +129 -0
- data/lib/fluent/plugin_helper/inject.rb +154 -0
- data/lib/fluent/plugin_helper/metrics.rb +136 -0
- data/lib/fluent/plugin_helper/parser.rb +147 -0
- data/lib/fluent/plugin_helper/record_accessor.rb +207 -0
- data/lib/fluent/plugin_helper/retry_state.rb +219 -0
- data/lib/fluent/plugin_helper/server.rb +840 -0
- data/lib/fluent/plugin_helper/service_discovery/manager.rb +146 -0
- data/lib/fluent/plugin_helper/service_discovery/round_robin_balancer.rb +43 -0
- data/lib/fluent/plugin_helper/service_discovery.rb +125 -0
- data/lib/fluent/plugin_helper/socket.rb +288 -0
- data/lib/fluent/plugin_helper/socket_option.rb +98 -0
- data/lib/fluent/plugin_helper/storage.rb +349 -0
- data/lib/fluent/plugin_helper/thread.rb +180 -0
- data/lib/fluent/plugin_helper/timer.rb +92 -0
- data/lib/fluent/plugin_helper.rb +75 -0
- data/lib/fluent/plugin_id.rb +93 -0
- data/lib/fluent/process.rb +22 -0
- data/lib/fluent/registry.rb +117 -0
- data/lib/fluent/root_agent.rb +468 -0
- data/lib/fluent/rpc.rb +95 -0
- data/lib/fluent/source_only_buffer_agent.rb +102 -0
- data/lib/fluent/static_config_analysis.rb +195 -0
- data/lib/fluent/supervisor.rb +1347 -0
- data/lib/fluent/system_config.rb +213 -0
- data/lib/fluent/test/base.rb +83 -0
- data/lib/fluent/test/driver/base.rb +231 -0
- data/lib/fluent/test/driver/base_owned.rb +83 -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 +61 -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/storage.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 +138 -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 +44 -0
- data/lib/fluent/test.rb +61 -0
- data/lib/fluent/time.rb +513 -0
- data/lib/fluent/timezone.rb +171 -0
- data/lib/fluent/tls.rb +105 -0
- data/lib/fluent/unique_id.rb +39 -0
- data/lib/fluent/variable_store.rb +40 -0
- data/lib/fluent/version.rb +21 -0
- data/lib/fluent/win32api.rb +38 -0
- data/lib/fluent/winsvc.rb +130 -0
- data/templates/new_gem/.gitignore +8 -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 +28 -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/lib/fluent/plugin/storage.rb.erb +40 -0
- data/templates/new_gem/test/helper.rb.erb +7 -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/new_gem/test/plugin/test_storage.rb.erb +18 -0
- data/templates/plugin_config_formatter/param.md-compact.erb +25 -0
- data/templates/plugin_config_formatter/param.md-table.erb +10 -0
- data/templates/plugin_config_formatter/param.md.erb +34 -0
- data/templates/plugin_config_formatter/section.md.erb +12 -0
- metadata +996 -0
data/lib/fluent/rpc.rb
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
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 'webrick'
|
|
18
|
+
|
|
19
|
+
module Fluent
|
|
20
|
+
module RPC
|
|
21
|
+
class Server
|
|
22
|
+
def initialize(endpoint, log)
|
|
23
|
+
m = endpoint.match(/^\[?(?<host>[0-9a-zA-Z:\-\.]+)\]?:(?<port>[0-9]+)$/)
|
|
24
|
+
raise Fluent::ConfigError, "Invalid rpc_endpoint: #{endpoint}" unless m
|
|
25
|
+
@bind = m[:host]
|
|
26
|
+
@port = m[:port]
|
|
27
|
+
@log = log
|
|
28
|
+
|
|
29
|
+
@server = WEBrick::HTTPServer.new(
|
|
30
|
+
BindAddress: @bind,
|
|
31
|
+
Port: @port,
|
|
32
|
+
Logger: WEBrick::Log.new(STDERR, WEBrick::Log::FATAL),
|
|
33
|
+
AccessLog: [],
|
|
34
|
+
)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def mount(path, servlet, *args)
|
|
38
|
+
@server.mount(path, servlet, *args)
|
|
39
|
+
@log.debug "register #{path} RPC servlet"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def mount_proc(path, &block)
|
|
43
|
+
@server.mount_proc(path) { |req, res|
|
|
44
|
+
begin
|
|
45
|
+
code, header, response = block.call(req, res)
|
|
46
|
+
rescue => e
|
|
47
|
+
@log.warn "failed to handle RPC request", path: path, error: e.to_s
|
|
48
|
+
@log.warn_backtrace e.backtrace
|
|
49
|
+
|
|
50
|
+
code = 500
|
|
51
|
+
body = {
|
|
52
|
+
'message '=> 'Internal Server Error',
|
|
53
|
+
'error' => "#{e}",
|
|
54
|
+
'backtrace'=> e.backtrace,
|
|
55
|
+
}
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
code = 200 if code.nil?
|
|
59
|
+
header = {'Content-Type' => 'application/json'} if header.nil?
|
|
60
|
+
body = if response.nil?
|
|
61
|
+
'{"ok":true}'
|
|
62
|
+
else
|
|
63
|
+
response.body['ok'] = code == 200
|
|
64
|
+
response.body.to_json
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
res.status = code
|
|
68
|
+
header.each_pair { |k, v|
|
|
69
|
+
res[k] = v
|
|
70
|
+
}
|
|
71
|
+
res.body = body
|
|
72
|
+
}
|
|
73
|
+
@log.debug "register #{path} RPC handler"
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def start
|
|
77
|
+
@log.debug "listening RPC http server on http://#{@bind}:#{@port}/"
|
|
78
|
+
@thread = Thread.new {
|
|
79
|
+
@server.start
|
|
80
|
+
}
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def shutdown
|
|
84
|
+
if @server
|
|
85
|
+
@server.shutdown
|
|
86
|
+
@server = nil
|
|
87
|
+
end
|
|
88
|
+
if @thread
|
|
89
|
+
@thread.join
|
|
90
|
+
@thread = nil
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
@@ -0,0 +1,102 @@
|
|
|
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/agent'
|
|
18
|
+
require 'fluent/system_config'
|
|
19
|
+
|
|
20
|
+
module Fluent
|
|
21
|
+
class SourceOnlyBufferAgent < Agent
|
|
22
|
+
# Use INSTANCE_ID to use the same base dir as the other workers.
|
|
23
|
+
# This will make recovery easier.
|
|
24
|
+
BUFFER_DIR_NAME = Fluent::INSTANCE_ID
|
|
25
|
+
|
|
26
|
+
def initialize(log:, system_config:)
|
|
27
|
+
super(log: log)
|
|
28
|
+
|
|
29
|
+
@default_buffer_path = File.join(system_config.root_dir || DEFAULT_BACKUP_DIR, 'source-only-buffer', BUFFER_DIR_NAME)
|
|
30
|
+
@optional_buffer_config = system_config.source_only_buffer.to_h.transform_keys(&:to_s)
|
|
31
|
+
@base_buffer_dir = nil
|
|
32
|
+
@actual_buffer_dir = nil
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def configure(flush: false)
|
|
36
|
+
buffer_config = @optional_buffer_config.compact
|
|
37
|
+
buffer_config['flush_at_shutdown'] = flush ? 'true' : 'false'
|
|
38
|
+
buffer_config['flush_thread_count'] = 0 unless flush
|
|
39
|
+
buffer_config['path'] ||= @default_buffer_path
|
|
40
|
+
|
|
41
|
+
super(
|
|
42
|
+
Config::Element.new('SOURCE_ONLY_BUFFER', '', {}, [
|
|
43
|
+
Config::Element.new('match', '**', {'@type' => 'buffer', '@label' => '@ROOT'}, [
|
|
44
|
+
Config::Element.new('buffer', '', buffer_config, [])
|
|
45
|
+
])
|
|
46
|
+
])
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
@base_buffer_dir = buffer_config['path']
|
|
50
|
+
# It can be "#{@base_buffer_dir}/worker#{fluentd_worker_id}/" when using multiple workers
|
|
51
|
+
@actual_buffer_dir = File.dirname(outputs[0].buffer.path)
|
|
52
|
+
|
|
53
|
+
unless flush
|
|
54
|
+
log.info "with-source-only: the emitted data will be stored in the buffer files under" +
|
|
55
|
+
" #{@base_buffer_dir}. You can send SIGWINCH to the supervisor process to cancel" +
|
|
56
|
+
" with-source-only mode and process data."
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def cleanup
|
|
61
|
+
unless (Dir.empty?(@actual_buffer_dir) rescue true)
|
|
62
|
+
log.warn "some buffer files remain in #{@base_buffer_dir}." +
|
|
63
|
+
" Please consider recovering or saving the buffer files in the directory." +
|
|
64
|
+
" To recover them, you can set the buffer path manually to system config and" +
|
|
65
|
+
" retry, i.e., restart Fluentd with with-source-only mode and send SIGWINCH again." +
|
|
66
|
+
" Config Example:\n#{config_example_to_recover(@base_buffer_dir)}"
|
|
67
|
+
return
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
begin
|
|
71
|
+
FileUtils.remove_dir(@base_buffer_dir)
|
|
72
|
+
rescue Errno::ENOENT
|
|
73
|
+
# This worker doesn't need to do anything. Another worker may remove the dir first.
|
|
74
|
+
rescue => e
|
|
75
|
+
log.warn "failed to remove the buffer directory: #{@base_buffer_dir}", error: e
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def emit_error_event(tag, time, record, error)
|
|
80
|
+
error_info = {error: error, location: (error.backtrace ? error.backtrace.first : nil), tag: tag, time: time, record: record}
|
|
81
|
+
log.warn "SourceOnlyBufferAgent: dump an error event:", error_info
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def handle_emits_error(tag, es, error)
|
|
85
|
+
error_info = {error: error, location: (error.backtrace ? error.backtrace.first : nil), tag: tag}
|
|
86
|
+
log.warn "SourceOnlyBufferAgent: emit transaction failed:", error_info
|
|
87
|
+
log.warn_backtrace
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
private
|
|
91
|
+
|
|
92
|
+
def config_example_to_recover(path)
|
|
93
|
+
<<~EOC
|
|
94
|
+
<system>
|
|
95
|
+
<source_only_buffer>
|
|
96
|
+
path #{path}
|
|
97
|
+
</source_only_buffer>
|
|
98
|
+
</system>
|
|
99
|
+
EOC
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
@@ -0,0 +1,195 @@
|
|
|
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/config'
|
|
18
|
+
require 'fluent/plugin'
|
|
19
|
+
|
|
20
|
+
module Fluent
|
|
21
|
+
# Static Analysis means analysing all plugins and Fluent::Element without invoking Plugin#configure
|
|
22
|
+
class StaticConfigAnalysis
|
|
23
|
+
module Elem
|
|
24
|
+
Input = Struct.new(:plugin, :config)
|
|
25
|
+
Output = Struct.new(:plugin, :config)
|
|
26
|
+
Filter = Struct.new(:plugin, :config)
|
|
27
|
+
Label = Struct.new(:name, :config, :nodes)
|
|
28
|
+
Worker = Struct.new(:ids, :config, :nodes)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
Result = Struct.new(:tree, :outputs, :inputs, :filters, :labels) do
|
|
32
|
+
def all_plugins
|
|
33
|
+
(outputs + inputs + filters).map(&:plugin)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# @param workers [Integer] Number of workers
|
|
38
|
+
# @return [Fluent::StaticConfigAnalysis::Result]
|
|
39
|
+
def self.call(conf, workers: 1)
|
|
40
|
+
new(workers).call(conf)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def initialize(workers)
|
|
44
|
+
@workers = workers
|
|
45
|
+
|
|
46
|
+
reset
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def call(config)
|
|
50
|
+
reset
|
|
51
|
+
|
|
52
|
+
tree = [
|
|
53
|
+
static_worker_analyse(config),
|
|
54
|
+
static_label_analyse(config),
|
|
55
|
+
static_filter_and_output_analyse(config),
|
|
56
|
+
static_input_analyse(config),
|
|
57
|
+
].flatten
|
|
58
|
+
|
|
59
|
+
Result.new(tree, @outputs, @inputs, @filters, @labels.values)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
private
|
|
63
|
+
|
|
64
|
+
def reset
|
|
65
|
+
@outputs = []
|
|
66
|
+
@inputs = []
|
|
67
|
+
@filters = []
|
|
68
|
+
@labels = {}
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def static_worker_analyse(conf)
|
|
72
|
+
available_worker_ids = [*0...@workers]
|
|
73
|
+
|
|
74
|
+
ret = []
|
|
75
|
+
supported_directives = %w[source match filter label]
|
|
76
|
+
conf.elements(name: 'worker').each do |config|
|
|
77
|
+
ids = parse_worker_id(config)
|
|
78
|
+
ids.each do |id|
|
|
79
|
+
if available_worker_ids.include?(id)
|
|
80
|
+
available_worker_ids.delete(id)
|
|
81
|
+
else
|
|
82
|
+
raise Fluent::ConfigError, "specified worker_id<#{id}> collisions is detected on <worker> directive. Available worker id(s): #{available_worker_ids}"
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
config.elements.each do |elem|
|
|
87
|
+
unless supported_directives.include?(elem.name)
|
|
88
|
+
raise Fluent::ConfigError, "<worker> section cannot have <#{elem.name}> directive"
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
nodes = [
|
|
93
|
+
static_label_analyse(config),
|
|
94
|
+
static_filter_and_output_analyse(config),
|
|
95
|
+
static_input_analyse(config),
|
|
96
|
+
].flatten
|
|
97
|
+
ret << Elem::Worker.new(ids, config, nodes)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
ret
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def parse_worker_id(conf)
|
|
104
|
+
worker_id_str = conf.arg
|
|
105
|
+
|
|
106
|
+
if worker_id_str.empty?
|
|
107
|
+
raise Fluent::ConfigError, 'Missing worker id on <worker> directive'
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
l, r =
|
|
111
|
+
begin
|
|
112
|
+
worker_id_str.split('-', 2).map { |v| Integer(v) }
|
|
113
|
+
rescue TypeError, ArgumentError
|
|
114
|
+
raise Fluent::ConfigError, "worker id should be integer: #{worker_id_str}"
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
if l < 0 || l >= @workers
|
|
118
|
+
raise Fluent::ConfigError, "worker id #{l} specified by <worker> directive is not allowed. Available worker id is between 0 and #{@workers-1}"
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# e.g. specified one worker id like `<worker 0>`
|
|
122
|
+
if r.nil?
|
|
123
|
+
return [l]
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
if r < 0 || r >= @workers
|
|
127
|
+
raise Fluent::ConfigError, "worker id #{r} specified by <worker> directive is not allowed. Available worker id is between 0 and #{@workers-1}"
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
if l > r
|
|
131
|
+
raise Fluent::ConfigError, "greater first_worker_id<#{l}> than last_worker_id<#{r}> specified by <worker> directive is not allowed. Available multi worker assign syntax is <smaller_worker_id>-<greater_worker_id>"
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
[l, r]
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def static_label_analyse(conf)
|
|
138
|
+
ret = []
|
|
139
|
+
conf.elements(name: 'label').each do |e|
|
|
140
|
+
name = e.arg
|
|
141
|
+
if name.empty?
|
|
142
|
+
raise ConfigError, 'Missing symbol argument on <label> directive'
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
if @labels[name]
|
|
146
|
+
raise ConfigError, "Section <label #{name}> appears twice"
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
l = Elem::Label.new(name, e, static_filter_and_output_analyse(e))
|
|
150
|
+
ret << l
|
|
151
|
+
@labels[name] = l
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
ret
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def static_filter_and_output_analyse(conf)
|
|
158
|
+
ret = []
|
|
159
|
+
conf.elements('filter', 'match').each do |e|
|
|
160
|
+
type = e['@type']
|
|
161
|
+
if type.nil? || type.empty?
|
|
162
|
+
raise Fluent::ConfigError, "Missing '@type' parameter on <#{e.name}> directive"
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
if e.name == 'filter'
|
|
166
|
+
f = Elem::Filter.new(Fluent::Plugin.new_filter(type), e)
|
|
167
|
+
ret << f
|
|
168
|
+
@filters << f
|
|
169
|
+
else
|
|
170
|
+
o = Elem::Output.new(Fluent::Plugin.new_output(type), e)
|
|
171
|
+
ret << o
|
|
172
|
+
@outputs << o
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
ret
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
def static_input_analyse(conf)
|
|
180
|
+
ret = []
|
|
181
|
+
conf.elements(name: 'source').each do |e|
|
|
182
|
+
type = e['@type']
|
|
183
|
+
if type.nil? || type.empty?
|
|
184
|
+
raise Fluent::ConfigError, "Missing '@type' parameter on <#{e.name}> directive"
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
i = Elem::Input.new(Fluent::Plugin.new_input(type), e)
|
|
188
|
+
@inputs << i
|
|
189
|
+
ret << i
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
ret
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
end
|