Class: Fluent::Plugin::GelfOutput
- Inherits:
-
Output
- Object
- Output
- Fluent::Plugin::GelfOutput
show all
- Includes:
- GelfPluginUtil
- Defined in:
- lib/fluent/plugin/out_gelf.rb
Constant Summary
collapse
- DEFAULT_BUFFER_TYPE =
'memory'.freeze
- DEFAULT_TIMEKEY =
5
- DEFAULT_TIMEKEY_WAIT =
0
- MAX_PAYLOAD_SIZE =
1000000
GelfPluginUtil::LEVEL_MAP
Instance Method Summary
collapse
#make_gelfentry
Instance Method Details
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/fluent/plugin/out_gelf.rb', line 44
def configure(conf)
super(conf)
raise Fluent::ConfigError.new("'host' parameter (hostname or address of Graylog2 server) is required") unless conf.has_key?('host')
if @protocol == 'udp' then @proto = GELF::Protocol::UDP
elsif @protocol == 'tcp' then @proto = GELF::Protocol::TCP
else raise Fluent::ConfigError.new("'protocol' parameter should be either 'udp' (default) or 'tcp'")
end
end
|
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/fluent/plugin/out_gelf.rb', line 81
def format(tag, time, record)
begin
make_gelfentry(
tag,time,record,
{
:use_record_host => @use_record_host,
:add_msec_time => @add_msec_time,
:max_bytes => @max_bytes
}
).to_msgpack
rescue Exception => e
log.error sprintf(
'Error trying to serialize %s: %s',
record.to_s.force_encoding('UTF-8'),
e.message.to_s.force_encoding('UTF-8')
)
end
end
|
40
41
42
|
# File 'lib/fluent/plugin/out_gelf.rb', line 40
def formatted_to_msgpack_binary
true
end
|
#multi_workers_ready? ⇒ Boolean
36
37
38
|
# File 'lib/fluent/plugin/out_gelf.rb', line 36
def multi_workers_ready?
true
end
|
#shutdown ⇒ Object
77
78
79
|
# File 'lib/fluent/plugin/out_gelf.rb', line 77
def shutdown
super
end
|
#start ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/fluent/plugin/out_gelf.rb', line 58
def start
super
options = {:facility => 'fluentd', :protocol => @proto}
if @tls then
options[:tls] = @tls_options
end
@conn = GELF::Notifier.new(@host, @port, @max_chunk_size_type, options)
@conn.level_mapping = 'direct'
@conn.collect_file_and_line = false
end
|
#write(chunk) ⇒ Object
101
102
103
104
105
106
107
108
109
110
|
# File 'lib/fluent/plugin/out_gelf.rb', line 101
def write(chunk)
chunk.msgpack_each do |data|
begin
@conn.notify!(data)
rescue Exception => e
log.warn "failed to flush the buffer.", error_class: e.class.to_s, error: e.to_s, plugin_id: plugin_id
raise e
end
end
end
|