Hi!
Before opening a ticket I would like to discuss my issue here.
I receive a event.message string encoded in UTF-8 even though I specify codec => plain { charset => "ASCII-8BIT"} in my config.
Here my config:
input {
http {
host => "0.0.0.0"
port => 8080
codec => plain { charset => "ASCII-8BIT"}
}
}
filter {
example {
}
}
output {
stdout { codec => rubydebug }
}
Here an extract my custom filter:
public
def filter(event)
@logger.debug? && @logger.debug("The event.message size is: #{event.get("message").size()}") @logger.debug? && @logger.debug("The event.message encoding is: #{event.get("message").encoding}")
counter = 0; event.get("message").each_byte { |c|
#Increments the counter for each byte within the string
counter +=1
}
@logger.debug? && @logger.debug("There are #{counter} bytes in the string")# filter_matched should go in the last line of our successful code filter_matched(event)
end # def filter
And here the output (I expect The event.message encoding is: ASCII-8BIT)
filter received {:event=>{"message"=>"H\u0000\u0002\u0001\a\u0000\u0000\u0000\u0001\u0002\u0003\u0004\u0005C&\v\u0000\u0000\u0000\u0000\u0000\u0000�F\u0000\u0000"\v\u0000", "@version"=>"1", "@timestamp"=>"2016-10-11T23:32:52.277Z", "host"=>"192.168.1.130", "headers"=>{"request_method"=>"POST", "request_path"=>"/", "request_uri"=>"/", "http_version"=>"HTTP/1.1", "http_user_agent"=>"Mozilla/4.0 (compatible; AP:FiOS-Mercury/3.2.2.3.3.3.6; PL:Motorola-DCT/KA15.76.12.19AlderF.560; BX:VMS1100; UA:0000108336906021; U; en-US)", "http_host"=>"192.168.1.239:8080", "http_accept"=>"/", "content_type"=>"application/x-www-form-urlencoded", "content_length"=>"2880"}}, :level=>:debug, :file=>"(eval)", :line=>"41", :method=>"filter_func"}
The event.message size is: 2880 {:level=>:debug, :file=>"logstash/filters/example.rb", :line=>"18", :method=>"filter"}
The event.message encoding is: UTF-8 {:level=>:debug, :file=>"logstash/filters/example.rb", :line=>"19", :method=>"filter"}
There are 2898 bytes in the string {:level=>:debug, :file=>"logstash/filters/example.rb", :line=>"27", :method=>"filter"}