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/in_exec.rb,
lib/fluent/plugin/in_http.rb,
lib/fluent/plugin/in_tail.rb,
lib/fluent/plugin/storage.rb,
lib/fluent/plugin/buf_file.rb,
lib/fluent/plugin/in_dummy.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_syslog.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/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/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/formatter_single_value.rb,
lib/fluent/plugin/filter_record_transformer.rb
Defined Under Namespace
Modules: Compressable, FeatureAvailabilityChecker, OwnedByMixin
Classes: Apache2Parser, ApacheErrorParser, ApacheParser, BareOutput, Base, Buffer, CSVParser, CopyOutput, CsvFormatter, DebugAgentInput, DummyInput, ExecFilterOutput, ExecInput, ExecOutput, FileBuffer, FileOutput, Filter, Formatter, ForwardInput, ForwardOutput, GCStatInput, GrepFilter, 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, SecondaryFileOutput, SingleValueFormatter, StdoutFilter, StdoutFormatter, StdoutOutput, Storage, SyslogInput, SyslogParser, TSVFormatter, TSVParser, TailInput, TcpInput, UdpInput
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_')
- REGISTRIES =
[INPUT_REGISTRY, OUTPUT_REGISTRY, FILTER_REGISTRY, BUFFER_REGISTRY, PARSER_REGISTRY, FORMATTER_REGISTRY, STORAGE_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_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_storage(type, klass) ⇒ Object
Class Method Details
.add_plugin_dir(dir) ⇒ Object
92
93
94
95
96
97
|
# File 'lib/fluent/plugin.rb', line 92
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
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/fluent/plugin.rb', line 81
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
111
112
113
|
# File 'lib/fluent/plugin.rb', line 111
def self.new_buffer(type, parent: nil)
new_impl('buffer', BUFFER_REGISTRY, type, parent)
end
|
.new_filter(type) ⇒ Object
107
108
109
|
# File 'lib/fluent/plugin.rb', line 107
def self.new_filter(type)
new_impl('filter', FILTER_REGISTRY, type)
end
|
127
128
129
|
# File 'lib/fluent/plugin.rb', line 127
def self.new_formatter(type, parent: nil)
new_impl('formatter', FORMATTER_REGISTRY, type, parent)
end
|
.new_impl(kind, registry, type, parent = nil) ⇒ Object
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
# File 'lib/fluent/plugin.rb', line 144
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
|
99
100
101
|
# File 'lib/fluent/plugin.rb', line 99
def self.new_input(type)
new_impl('input', INPUT_REGISTRY, type)
end
|
.new_output(type) ⇒ Object
103
104
105
|
# File 'lib/fluent/plugin.rb', line 103
def self.new_output(type)
new_impl('output', OUTPUT_REGISTRY, type)
end
|
.new_parser(type, parent: nil) ⇒ Object
115
116
117
118
119
120
121
122
123
124
125
|
# File 'lib/fluent/plugin.rb', line 115
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_storage(type, parent: nil) ⇒ Object
131
132
133
|
# File 'lib/fluent/plugin.rb', line 131
def self.new_storage(type, parent: nil)
new_impl('storage', STORAGE_REGISTRY, type, parent)
end
|
.register_buffer(type, klass) ⇒ Object
53
54
55
|
# File 'lib/fluent/plugin.rb', line 53
def self.register_buffer(type, klass)
register_impl('buffer', BUFFER_REGISTRY, type, klass)
end
|
.register_filter(type, klass) ⇒ Object
49
50
51
|
# File 'lib/fluent/plugin.rb', line 49
def self.register_filter(type, klass)
register_impl('filter', FILTER_REGISTRY, type, klass)
end
|
67
68
69
70
71
72
73
74
75
|
# File 'lib/fluent/plugin.rb', line 67
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
135
136
137
138
139
140
141
142
|
# File 'lib/fluent/plugin.rb', line 135
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
|
41
42
43
|
# File 'lib/fluent/plugin.rb', line 41
def self.register_input(type, klass)
register_impl('input', INPUT_REGISTRY, type, klass)
end
|
.register_output(type, klass) ⇒ Object
45
46
47
|
# File 'lib/fluent/plugin.rb', line 45
def self.register_output(type, klass)
register_impl('output', OUTPUT_REGISTRY, type, klass)
end
|
.register_parser(type, klass_or_proc) ⇒ Object
57
58
59
60
61
62
63
64
65
|
# File 'lib/fluent/plugin.rb', line 57
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_storage(type, klass) ⇒ Object
77
78
79
|
# File 'lib/fluent/plugin.rb', line 77
def self.register_storage(type, klass)
register_impl('storage', STORAGE_REGISTRY, type, klass)
end
|