diff --git a/lib/fluent/plugin/out_gelf.rb b/lib/fluent/plugin/out_gelf.rb index 4b17fdc..f5b8e70 100644 --- a/lib/fluent/plugin/out_gelf.rb +++ b/lib/fluent/plugin/out_gelf.rb @@ -9,6 +9,8 @@ class GELFOutput < BufferedOutput config_param :host, :string, :default => nil config_param :port, :integer, :default => 12201 config_param :protocol, :string, :default => 'udp' + # Default max_bytes is set to avoid Elasticsearch indexing errors. + config_param :max_bytes, :integer, :default => 32000 def initialize super @@ -54,6 +56,9 @@ def format(tag, time, record) gelfentry = { :timestamp => timestamp, :_tag => tag } record.each_pair do |k,v| + # Truncate values longer than configured maximum + v = v.bytesize > @max_bytes ? "#{v.byteslice(0, @max_bytes - 3)}..." : v + case k when 'version' then gelfentry[:_version] = v