Urldecode error

Hi, everyone!
I can not encode with utf-8.

logstash filter:

urldecode { field => "kw_nm" }
ruby {
code => "
kw_nm = event.get('kw_nm')
kw_nm.force_encoding('ISO-8859-1').encode('UTF-8')
event.set('enc_kw_nm', kw_nm)
end
"
}

error code:

[2019-01-29T20:07:08,692][WARN ][logstash.filters.urldecode] Received an event that has a different character encoding than you configured. {:text=>"\xB5\xB5\xB8\xB6", :expected_charset=>"UTF-8"}

Can you give me a code example?

I corrected the error.

this is code:

ruby {
code => "
kw_nm = event.get('kw_nm')
if kw_nm.is_a? Array then
kw_nm = kw_nm.first
end
event.set('kw_nm', kw_nm)
event.set('kw_nm_euc', kw_nm)
"
}
urldecode { field => "kw_nm"}
if [kw_nm] =~ /\x/ {
urldecode { field => "kw_nm_euc" charset => "EUC-KR" }
ruby {
code => "
kw_nm = event.get('kw_nm_euc')
kw_nm = kw_nm.encode('UTF-8')
event.set('enc_kw_nm', kw_nm)
"
}
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.