Module: Fluent::Plugin
- Defined in:
- lib/fluent/plugin.rb,
lib/fluent/plugin/base.rb,
lib/fluent/plugin/input.rb,
lib/fluent/plugin/buffer.rb,
lib/fluent/plugin/filter.rb,
lib/fluent/plugin/in_tcp.rb,
lib/fluent/plugin/in_udp.rb,
lib/fluent/plugin/output.rb,
lib/fluent/plugin/parser.rb,
lib/fluent/plugin/sd_srv.rb,
lib/fluent/plugin/in_exec.rb,
lib/fluent/plugin/in_http.rb,
lib/fluent/plugin/in_tail.rb,
lib/fluent/plugin/in_unix.rb,
lib/fluent/plugin/sd_file.rb,
lib/fluent/plugin/storage.rb,
lib/fluent/plugin/buf_file.rb,
lib/fluent/plugin/out_copy.rb,
lib/fluent/plugin/out_exec.rb,
lib/fluent/plugin/out_file.rb,
lib/fluent/plugin/out_null.rb,
lib/fluent/plugin/formatter.rb,
lib/fluent/plugin/in_sample.rb,
lib/fluent/plugin/in_syslog.rb,
lib/fluent/plugin/sd_static.rb,
lib/fluent/plugin/buf_memory.rb,
lib/fluent/plugin/in_forward.rb,
lib/fluent/plugin/in_gc_stat.rb,
lib/fluent/plugin/out_stdout.rb,
lib/fluent/plugin/parser_csv.rb,
lib/fluent/plugin/parser_tsv.rb,
lib/fluent/plugin/bare_output.rb,
lib/fluent/plugin/filter_grep.rb,
lib/fluent/plugin/out_forward.rb,
lib/fluent/plugin/out_relabel.rb,
lib/fluent/plugin/parser_json.rb,
lib/fluent/plugin/parser_ltsv.rb,
lib/fluent/plugin/parser_none.rb,
lib/fluent/plugin/buffer/chunk.rb,
lib/fluent/plugin/compressable.rb,
lib/fluent/plugin/multi_output.rb,
lib/fluent/plugin/parser_nginx.rb,
lib/fluent/plugin/filter_parser.rb,
lib/fluent/plugin/filter_stdout.rb,
lib/fluent/plugin/formatter_csv.rb,
lib/fluent/plugin/formatter_tsv.rb,
lib/fluent/plugin/parser_apache.rb,
lib/fluent/plugin/parser_regexp.rb,
lib/fluent/plugin/parser_syslog.rb,
lib/fluent/plugin/storage_local.rb,
lib/fluent/plugin/formatter_hash.rb,
lib/fluent/plugin/formatter_json.rb,
lib/fluent/plugin/formatter_ltsv.rb,
lib/fluent/plugin/in_debug_agent.rb,
lib/fluent/plugin/out_roundrobin.rb,
lib/fluent/plugin/owned_by_mixin.rb,
lib/fluent/plugin/parser_apache2.rb,
lib/fluent/plugin/parser_msgpack.rb,
lib/fluent/plugin/buf_file_single.rb,
lib/fluent/plugin/in_object_space.rb,
lib/fluent/plugin/out_exec_filter.rb,
lib/fluent/plugin/formatter_stdout.rb,
lib/fluent/plugin/in_monitor_agent.rb,
lib/fluent/plugin/parser_multiline.rb,
lib/fluent/plugin/buffer/file_chunk.rb,
lib/fluent/plugin/formatter_msgpack.rb,
lib/fluent/plugin/out_forward/error.rb,
lib/fluent/plugin/service_discovery.rb,
lib/fluent/plugin/formatter_out_file.rb,
lib/fluent/plugin/out_secondary_file.rb,
lib/fluent/plugin/buffer/memory_chunk.rb,
lib/fluent/plugin/parser_apache_error.rb,
lib/fluent/plugin/in_tail/position_file.rb,
lib/fluent/plugin/formatter_single_value.rb,
lib/fluent/plugin/out_forward/ack_handler.rb,
lib/fluent/plugin/buffer/file_single_chunk.rb,
lib/fluent/plugin/out_forward/socket_cache.rb,
lib/fluent/plugin/filter_record_transformer.rb,
lib/fluent/plugin/out_forward/load_balancer.rb,
lib/fluent/plugin/out_forward/failure_detector.rb,
lib/fluent/plugin/out_forward/connection_manager.rb,
lib/fluent/plugin/out_forward/handshake_protocol.rb,
lib/fluent/plugin/out_http.rb
Defined Under Namespace
Modules: Compressable, FeatureAvailabilityChecker, Newline, OwnedByMixin
Classes: Apache2Parser, ApacheErrorParser, ApacheParser, BareOutput, Base, Buffer, CSVParser, CopyOutput, CsvFormatter, DebugAgentInput, ExecFilterOutput, ExecInput, ExecOutput, FileBuffer, FileOutput, FileServiceDiscovery, FileSingleBuffer, Filter, Formatter, ForwardInput, ForwardOutput, GCStatInput, GrepFilter, HTTPOutput, HashFormatter, HttpInput, InHttpParser, Input, JSONFormatter, JSONParser, LabeledTSVFormatter, LabeledTSVParser, LocalStorage, MemoryBuffer, MessagePackFormatter, MessagePackParser, MonitorAgentInput, MultiOutput, MultilineParser, NginxParser, NoneParser, NullOutput, ObjectSpaceInput, OutFileFormatter, Output, Parser, ParserFilter, ProcWrappedFormatter, RecordTransformerFilter, RegexpParser, RelabelOutput, RoundRobinOutput, SampleInput, SecondaryFileOutput, ServiceDiscovery, SingleValueFormatter, SrvServiceDiscovery, StaticServiceDiscovery, StdoutFilter, StdoutFormatter, StdoutOutput, Storage, SyslogInput, SyslogParser, TSVFormatter, TSVParser, TailInput, TcpInput, UdpInput, UnixInput
Constant Summary
collapse
- SEARCH_PATHS =
[]
- INPUT_REGISTRY =
first class plugins (instantiated by Engine)
Registry.new(:input, 'fluent/plugin/in_', dir_search_prefix: 'in_')
- OUTPUT_REGISTRY =
Registry.new(:output, 'fluent/plugin/out_', dir_search_prefix: 'out_')
- FILTER_REGISTRY =
Registry.new(:filter, 'fluent/plugin/filter_', dir_search_prefix: 'filter_')
- BUFFER_REGISTRY =
feature plugin: second class plugins (instantiated by Plugins or Helpers)
Registry.new(:buffer, 'fluent/plugin/buf_', dir_search_prefix: 'buf_')
- PARSER_REGISTRY =
Registry.new(:parser, 'fluent/plugin/parser_', dir_search_prefix: 'parser_')
- FORMATTER_REGISTRY =
Registry.new(:formatter, 'fluent/plugin/formatter_', dir_search_prefix: 'formatter_')
- STORAGE_REGISTRY =
Registry.new(:storage, 'fluent/plugin/storage_', dir_search_prefix: 'storage_')
- SD_REGISTRY =
Registry.new(:sd, 'fluent/plugin/sd_', dir_search_prefix: 'sd_')
- REGISTRIES =
[INPUT_REGISTRY, OUTPUT_REGISTRY, FILTER_REGISTRY, BUFFER_REGISTRY, PARSER_REGISTRY, FORMATTER_REGISTRY, STORAGE_REGISTRY, SD_REGISTRY]
Class Method Summary
collapse
-
.add_plugin_dir(dir) ⇒ Object
-
.lookup_type_from_class(klass_or_its_name) ⇒ Object
-
.new_buffer(type, parent: nil) ⇒ Object
-
.new_filter(type) ⇒ Object
-
.new_formatter(type, parent: nil) ⇒ Object
-
.new_impl(kind, registry, type, parent = nil) ⇒ Object
-
.new_input(type) ⇒ Object
-
.new_output(type) ⇒ Object
-
.new_parser(type, parent: nil) ⇒ Object
-
.new_sd(type, parent: nil) ⇒ Object
(also: new_service_discovery)
-
.new_storage(type, parent: nil) ⇒ Object
-
.register_buffer(type, klass) ⇒ Object
-
.register_filter(type, klass) ⇒ Object
-
.register_formatter(type, klass_or_proc) ⇒ Object
-
.register_impl(kind, registry, type, value) ⇒ Object
-
.register_input(type, klass) ⇒ Object
-
.register_output(type, klass) ⇒ Object
-
.register_parser(type, klass_or_proc) ⇒ Object
-
.register_sd(type, klass) ⇒ Object
-
.register_storage(type, klass) ⇒ Object
Class Method Details
.add_plugin_dir(dir) ⇒ Object
97
98
99
100
101
102
|
# File 'lib/fluent/plugin.rb', line 97
def self.add_plugin_dir(dir)
REGISTRIES.each do |r|
r.paths.push(dir)
end
nil
end
|
.lookup_type_from_class(klass_or_its_name) ⇒ Object
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/fluent/plugin.rb', line 86
def self.lookup_type_from_class(klass_or_its_name)
klass = if klass_or_its_name.is_a? Class
klass_or_its_name
elsif klass_or_its_name.is_a? String
eval(klass_or_its_name) else
raise ArgumentError, "invalid argument type #{klass_or_its_name.class}: #{klass_or_its_name}"
end
REGISTRIES.reduce(nil){|a, r| a || r.reverse_lookup(klass) }
end
|
.new_buffer(type, parent: nil) ⇒ Object
116
117
118
|
# File 'lib/fluent/plugin.rb', line 116
def self.new_buffer(type, parent: nil)
new_impl('buffer', BUFFER_REGISTRY, type, parent)
end
|
.new_filter(type) ⇒ Object
112
113
114
|
# File 'lib/fluent/plugin.rb', line 112
def self.new_filter(type)
new_impl('filter', FILTER_REGISTRY, type)
end
|
141
142
143
|
# File 'lib/fluent/plugin.rb', line 141
def self.new_formatter(type, parent: nil)
new_impl('formatter', FORMATTER_REGISTRY, type, parent)
end
|
.new_impl(kind, registry, type, parent = nil) ⇒ Object
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
# File 'lib/fluent/plugin.rb', line 158
def self.new_impl(kind, registry, type, parent=nil)
obj = registry.lookup(type)
impl = case
when obj.is_a?(Class)
obj.new
when obj.respond_to?(:call) && obj.arity == 0
obj.call
else
raise Fluent::ConfigError, "#{kind} plugin '#{type}' is not a Class nor callable (without arguments)."
end
if parent && impl.respond_to?("owner=")
impl.owner = parent
end
impl.extend FeatureAvailabilityChecker
impl
end
|
104
105
106
|
# File 'lib/fluent/plugin.rb', line 104
def self.new_input(type)
new_impl('input', INPUT_REGISTRY, type)
end
|
.new_output(type) ⇒ Object
108
109
110
|
# File 'lib/fluent/plugin.rb', line 108
def self.new_output(type)
new_impl('output', OUTPUT_REGISTRY, type)
end
|
.new_parser(type, parent: nil) ⇒ Object
129
130
131
132
133
134
135
136
137
138
139
|
# File 'lib/fluent/plugin.rb', line 129
def self.new_parser(type, parent: nil)
if type[0] == '/' && type[-1] == '/'
require 'fluent/parser'
impl = Fluent::TextParser.lookup(type)
impl.extend FeatureAvailabilityChecker
impl
else
new_impl('parser', PARSER_REGISTRY, type, parent)
end
end
|
.new_sd(type, parent: nil) ⇒ Object
Also known as:
new_service_discovery
120
121
122
|
# File 'lib/fluent/plugin.rb', line 120
def self.new_sd(type, parent: nil)
new_impl('sd', SD_REGISTRY, type, parent)
end
|
.new_storage(type, parent: nil) ⇒ Object
145
146
147
|
# File 'lib/fluent/plugin.rb', line 145
def self.new_storage(type, parent: nil)
new_impl('storage', STORAGE_REGISTRY, type, parent)
end
|
.register_buffer(type, klass) ⇒ Object
54
55
56
|
# File 'lib/fluent/plugin.rb', line 54
def self.register_buffer(type, klass)
register_impl('buffer', BUFFER_REGISTRY, type, klass)
end
|
.register_filter(type, klass) ⇒ Object
50
51
52
|
# File 'lib/fluent/plugin.rb', line 50
def self.register_filter(type, klass)
register_impl('filter', FILTER_REGISTRY, type, klass)
end
|
72
73
74
75
76
77
78
79
80
|
# File 'lib/fluent/plugin.rb', line 72
def self.register_formatter(type, klass_or_proc)
if klass_or_proc.respond_to?(:call) && klass_or_proc.arity == 3 require 'fluent/formatter'
register_impl('formatter', FORMATTER_REGISTRY, type, Proc.new { Fluent::TextFormatter::ProcWrappedFormatter.new(klass_or_proc) })
else
register_impl('formatter', FORMATTER_REGISTRY, type, klass_or_proc)
end
end
|
.register_impl(kind, registry, type, value) ⇒ Object
149
150
151
152
153
154
155
156
|
# File 'lib/fluent/plugin.rb', line 149
def self.register_impl(kind, registry, type, value)
if !value.is_a?(Class) && !value.respond_to?(:call)
raise Fluent::ConfigError, "Invalid implementation as #{kind} plugin: '#{type}'. It must be a Class, or callable."
end
registry.register(type, value)
$log.trace "registered #{kind} plugin '#{type}'" if defined?($log)
nil
end
|
42
43
44
|
# File 'lib/fluent/plugin.rb', line 42
def self.register_input(type, klass)
register_impl('input', INPUT_REGISTRY, type, klass)
end
|
.register_output(type, klass) ⇒ Object
46
47
48
|
# File 'lib/fluent/plugin.rb', line 46
def self.register_output(type, klass)
register_impl('output', OUTPUT_REGISTRY, type, klass)
end
|
.register_parser(type, klass_or_proc) ⇒ Object
62
63
64
65
66
67
68
69
70
|
# File 'lib/fluent/plugin.rb', line 62
def self.register_parser(type, klass_or_proc)
if klass_or_proc.is_a?(Regexp)
require 'fluent/parser'
register_impl('parser', PARSER_REGISTRY, type, Proc.new { Fluent::TextParser::RegexpParser.new(klass_or_proc) })
else
register_impl('parser', PARSER_REGISTRY, type, klass_or_proc)
end
end
|
.register_sd(type, klass) ⇒ Object
58
59
60
|
# File 'lib/fluent/plugin.rb', line 58
def self.register_sd(type, klass)
register_impl('sd', SD_REGISTRY, type, klass)
end
|
.register_storage(type, klass) ⇒ Object
82
83
84
|
# File 'lib/fluent/plugin.rb', line 82
def self.register_storage(type, klass)
register_impl('storage', STORAGE_REGISTRY, type, klass)
end
|