# Filter Error ASCII-8BIT to UTF-8

**URL:** https://discuss.elastic.co/t/filter-error-ascii-8bit-to-utf-8/124156
**Category:** Logstash
**Created:** [March 15, 2018, 6:00pm UTC](https://discuss.elastic.co/t/filter-error-ascii-8bit-to-utf-8/124156 "2018-03-15T18:00:16Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Kareny](https://avatars.discourse-cdn.com/v4/letter/k/3d9bf3/32.png) [@Kareny](https://discuss.elastic.co/u/Kareny)
#### Post date: [March 15, 2018, 6:00pm UTC](https://discuss.elastic.co/t/filter-error-ascii-8bit-to-utf-8/124156/1 "2018-03-15T18:00:16Z")

</div>

Hi, I got the following error when running the logstash with jdbc plugin to fetch logs from a oracle database.

> Mar 13 17:09:31 exabeamlms01 docker[10496]: [2018-03-13T17:09:31,010][ERROR]  
> [logstash.filters.ruby] Ruby exception occurred: ""\xA6"" from ASCII-8BIT to UTF-8  
> Mar 13 17:09:35 exabeamlms01 docker[10496]: [2018-03-13T17:09:35,997][ERROR][logstash.filters.ruby] Ruby exception occurred: ""\xCE"" from ASCII-8BIT to UTF-8  
> Mar 13 17:09:39 exabeamlms01 docker[10496]: [2018-03-13T17:09:39,606][ERROR][logstash.filters.ruby] Ruby exception occurred: ""\xB4"" from ASCII-8BIT to UTF-8  
> Mar 13 17:09:39 exabeamlms01 docker[10496]: [2018-03-13T17:09:39,884][ERROR][logstash.filters.ruby] Ruby exception occurred: ""\xB7"" from ASCII-8BIT to UTF-8

Here's my config for the jdbc input:  
input { jdbc { codec =\> line jdbc\_driver\_library =\>"/opt/jdbc-drivers/ojdbc8.jar" jdbc\_driver\_class =\> "Java::oracle.jdbc.driver.OracleDriver" jdbc\_connection\_string =\> "jdbc:oracle:thin:@(DESCRIPTION=(CONNECT\_TIMEOUT=1)(TRANSPORT\_CONNECT\_TIMEOUT=1)(RETRY\_COUNT=1)(ADDRESS\_LIST=(LOAD\_BALANCE=off)(FAILOVER=on)(ADDRESS=(HOST=wittet)(PORT=1521)(PROTOCOL=TCP))(ADDRESS=(HOST=exa03-scan.wittet)(PORT=1521)(PROTOCOL=TCP)))(CONNECT\_DATA=(SERVICE\_NAME=sedbsrv.db)(FAILOVER\_MODE=(TYPE=SELECT)(METHOD=BASIC))))" jdbc\_user =\> "XXXX" jdbc\_password =\> "XXX" schedule =\> "\* \* \* \* \*" statement =\> "SELECT \* from unified\_audit\_trail WHERE Event\_timestamp \> :sql\_last\_value" use\_column\_value =\> false tracking\_column =\> ORIGINATING\_TIMESTAMP last\_run\_metadata\_path =\> "/opt/exabeam/co`nfig/.last\_run" } }

This is my filter and output config:  
filter {  
ruby {  
init =\> 'require "json"'  
code =\> '  
message = {}  
keys = event.to\_hash.keys  
keys.each {|key|  
if key != "@timestamp" then  
message[key] = event.get(key)  
event.remove(key)  
end  
}  
event.set("message", message.to\_json)  
'  
}  
}  
output {  
kafka {  
topic\_id =\> "kafka.topic"  
bootstrap\_servers =\> "KAFKA\_HOST:9092"  
codec =\> json\_lines  
}  
}

I tried the following settings but none of these solved the issue:  
codec =\> plain { charset =\> "ASCII-8BIT" }  
codec =\> plain { charset =\> "UTF-8" }  
codec =\> line

I'm running Logstash **5.4** , not sure if this issue will exist in **6.1** tho.

Did anyone see this issue before?

---

<div class="post-metadata">

### Author: ![yaauie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yaauie/32/23363_2.png) [@yaauie](https://discuss.elastic.co/u/yaauie)
#### Post date: [March 15, 2018, 6:29pm UTC](https://discuss.elastic.co/t/filter-error-ascii-8bit-to-utf-8/124156/2 "2018-03-15T18:29:32Z")

</div>

The [`columns_charset`](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-jdbc.html#plugins-inputs-jdbc-columns_charset) option of `logstash-input-jdbc` allows you to specify the charset of individual columns:

```auto
input {
  jdbc {
    columns_charset => {
      "some_field" => "BINARY"
      "another_field" => "UTF-8"
    }
    # ...
  }
}

```

---

<div class="post-metadata">

### Author: ![wwalker](https://avatars.discourse-cdn.com/v4/letter/w/43a26b/32.png) [@wwalker](https://discuss.elastic.co/u/wwalker)
#### Post date: [March 15, 2018, 7:38pm UTC](https://discuss.elastic.co/t/filter-error-ascii-8bit-to-utf-8/124156/3 "2018-03-15T19:38:33Z")

</div>

Possibly unrelated, but the same error occurs with the XML filter when used with persisted disk queuing. Are you using persisted disk in your logstash.yml config? There's a known issue out there on GitHub for this as well.

---

<div class="post-metadata">

### Author: ![Kareny](https://avatars.discourse-cdn.com/v4/letter/k/3d9bf3/32.png) [@Kareny](https://discuss.elastic.co/u/Kareny)
#### Post date: [April 5, 2018, 10:22pm UTC](https://discuss.elastic.co/t/filter-error-ascii-8bit-to-utf-8/124156/4 "2018-04-05T22:22:50Z")

</div>

I tried the charset for codec but that does not work for me. I figure out the fix myself.  
In the ruby filter I have to force encode all strings using:

```
if value.is_a? String then
    value = value.force_encoding("ISO-8859-15").encode("UTF-8")
end
```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [May 3, 2018, 10:23pm UTC](https://discuss.elastic.co/t/filter-error-ascii-8bit-to-utf-8/124156/5 "2018-05-03T22:23:11Z")

</div>

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