Class: LogStash::Filters::Truncate
- Inherits:
-
Base
- Object
- Base
- LogStash::Filters::Truncate
- Defined in:
- lib/logstash/filters/truncate.rb
Overview
Allows you to truncate fields longer than a given length.
This truncates on bytes values, not character count. In practice, this should mean that the truncated length is somewhere between ‘length_bytes` and `length_bytes - 6` (UTF-8 supports up to 6-byte characters).
Defined Under Namespace
Modules: Truncator
Instance Method Summary collapse
Instance Method Details
#filter(event) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/logstash/filters/truncate.rb', line 41 def filter(event) if @fields truncated = Truncator.truncate_all(fields, event, @length_bytes) else # TODO(sissel): I couldn't find a better way to get the top level keys for # an event. Nor could I find a way to iterate over all the keys in an # event, so this may have to suffice. fields = event.to_hash.keys.map { |k| "[#{k}]" } truncated = Truncator.truncate_all(fields, event, @length_bytes) end if truncated @logger.debug("truncated one or more fields from event to length #{@length_bytes}") filter_matched(event) end end |
#register ⇒ Object
37 38 39 |
# File 'lib/logstash/filters/truncate.rb', line 37 def register # nothing end |