# TCP-input Receiving an encoding error

**URL:** <https://discuss.elastic.co/t/tcp-input-receiving-an-encoding-error/321344>\
**Category:** Logstash\
**Created:** [December 15, 2022, 8:02pm UTC](https://discuss.elastic.co/t/tcp-input-receiving-an-encoding-error/321344 "2022-12-15T20:02:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![elrozario](https://avatars.discourse-cdn.com/v4/letter/e/8e8cbc/32.png) [@elrozario](https://discuss.elastic.co/u/elrozario)\
**Post date:** [December 15, 2022, 8:02pm UTC](https://discuss.elastic.co/t/tcp-input-receiving-an-encoding-error/321344/1 "2022-12-15T20:02:29Z")

</div>

Hello,  
I have a TCP input and getting data with some special characters. How do I resolve this issue?

Here is my config

```auto

input {
    tcp {
        host => "0.0.0.0"
        port => "0000"
        mode => "server"
        type => "graphite-format-metrics"
        codec => graphite 
    }

}
filter {
     mutate{
        #gsub => ["message","\\u0000",""]
        #gsub => ["message", "\x86", ""]
        gsub => ["message", "\\u0018", ""]
        gsub => ["message", "¥",""]
        gsub => ["message", "[\[]",""]
        gsub => ["message", "[\]]",""]
        gsub => ["message", "[\\]", ""]
}
}
output {
    stdout { codec => rubydebug }

    elasticsearch {
            ndex => "logstash-graphite-%{+YYYY.MM.dd}"
        }
}

```

As you can see, I have tried to strip the unicode charecters with gsub in my filter. Getting the following so many times.

``` Received an event that has a different character encoding than you configured. {:text=\>"ㆆq\u0002a.\u0000\u0000\u0000R\x80\u0002]q\u0001U3terminal.029666.top.\_opt\_morpho\_bin\_hardmond.topcpuGA\xD8\xE6ݴ\u0000\u0000\u0000G\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002a.\u0000\u0000\u0000\x99\x80\u0002]q\u0001(U#terminal.025930.top..\_pweupl.topmemGA\xD8\xE6\xDD\xC2\xC0\u0000\u0000G@\u0000\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002U\>terminal.027151.df-mnt-configuration-lotsys.percent\_bytes-usedGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G?\xCA\u0015+?\xFF\xFF\xFD\x86\x86q\u0003e.\u0000\u0000\u0000H\x80\u0002]q\u0001U)terminal.029972.top.{chromium-bin}.topcpuGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G@\b\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002a.\u0000\u0000\u0000n\x80\u0002]q\u0001(U\eTC.RDL027702.memory.freeRamGA\xD8\xE6ݥ@\u0000\u0000GA\u0016Q\xE0\u0000\u0000\u0000\u0000\x86\x86q\u0002U\eTC.RDL027702.memory.freeRamGA\xD8\xE6ݴ@\u0000\u0000GA\u0016M\xE0\u0000\u0000\u0000\u0000\x86\x86q\u0003e.\u0000\u0000\u0000A\x80\u0002]q\u0001U\"terminal.019628.cpu.percent-activeGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G@\<h\u0016\xD2J+~\x86\x86q\u0002a.\u0000\u0000\u0000f\x80\u0002]q\u0001(U\u0017TC.RDL031044.version.OSGA\xD8\xE6ݥ@\u0000\u0000G@\xB5\x87\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002U\u0017TC.RDL031044.version.OSGA\xD8\xE6ݴ@\u0000\u0000G@\xB5\x87\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0003e.\u0000\u0000\u0000ƀ\u0002]q\u0001(U\"terminal.024919.top.COMMAND.topmemGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002U,terminal.024919.top..\_pwedwnmgrtester.topmemGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G@\u0000\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0003U(terminal.024919.top.[kworker\_2.1].topcpuGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G@\b\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0004e.\u0000\u0000\u0000\x83\x80\u0002]q\u0001(U&terminal.024438.top..\_pweuplmgr.topmemGA\xD8\xE6ݴ\u0000\u0000\u0000G@\u0000\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002U%terminal.024438.memory.percent-cachedGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G@Ju\xB0\u000E\x8C۸\x86\x86q\u0003e.\u0000\u0000\u0000D\x80\u0002]q\u0001U%terminal.027777.top.\_usr\_bin\_X.topcpuGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002a.\u0000\u0000\u0000K\x80\u0002]q\u0001U,terminal.027653.top..\_pwedwnmgrtester.topmemGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G@\u0000\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002a.\u0000\u0000\u0000B\x80\u0002]q\u0001U#terminal.029972.top.collectd.topmemGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G@(\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002a.\u0000\u0000\u0000=\x80\u0002]q\u0001U\u001Eterminal.028190.top.top.topcpuGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G@\u0000\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002a.\u0000\u0000\u0000\x9C\x80\u0002]q\u0001(U;terminal.028867.df-mnt-configuration-lotsys.df\_complex-usedGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000GA^ \u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002U)terminal.028867.top.{chromium-bin}.topcpuGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G@\u0014\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0003e.\u0000\u0000\u0000B\x80\u0002]q\u0001U#terminal.028190.top..\_pwedwn.topmemGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G@\u0014\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002a.\u0000\u0000\u0000p\x80\u0002]q\u0001(U\u001CTC.RDL031259.memory.totalRamGA\xD8\xE6ݥ@\u0000\u0000GA/U\xA0\u0000\u0000\u0000\u0000\x86\x86q\u0002U\u001CTC.RDL031259.memory.totalRamGA\xD8\xE6ݴ@\u0000\u0000GA/U\xA0\u0000\u0000\u0000\u0000\x86\x86q\u0003e.\u0000\u0000\u0000ր\u0002]q\u0001(U-terminal.027151.top.\_usr\_sbin\_rsyslogd.topcpuGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002U&terminal.027151.top..\_pwedwnmgr.topcpuGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0003U3terminal.019329.top.\_opt\_morpho\_bin\_hardmond.topmemGA\xD8\xE6ݴ\x80\u0000\u0000G?\xF0\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0004e.\u0000\u0000\u0000ʀ\u0002]q\u0001(U(terminal.028949.top.[kworker\_3.0].topcpuGA\xD8\xE6ݴ\u0000\u0000\u0000G@\u0000\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002U(terminal.028949.memory.percent-slab\_reclGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G?\xE7\xF8K\u0014u\xDA͆\x86q\u0003U_terminal.028949.memory.percent-slab\_unreclGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G?\xEFz\u0002\xB9\xAB\xEC_\x86\x86q\u0004e.\u0000\u0000\u0000T\x80\u0002]q\u0001U5terminal.020744.df-versions-active.percent\_bytes-usedGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G@A\xF0E\x80\u0000\u0000\u0002\x86\x86q\u0002a.\u0000\u0000\u0000Q\x80\u0002]q\u0001U2terminal.028841.top.\_opt\_app\_LT\_application.topmemGA\xD8\xE6ݴ\u0000\u0000\u0000G@Q@\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002a.\u0000\u0000\u0000W\x80\u0002]q\u0001U8terminal.024269.sensors-w83627uhg-isa-0290.fanspeed-fan1GA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G@\x9D\xF4\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002a.\u0000\u0000\u0000B\x80\u0002]q\u0001U#terminal.019628.top..\_pweupl.topmemGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G@\u0000\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002a.\u0000\u0000\u0000Q\x80\u0002]q\u0001U2terminal.028022.top.\_opt\_app\_LT\_application.topcpuGA\xD8\xE6ݴ@\u0000\u0000G@\u0014\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002a.\u0000\u0000\u0000Z\x80\u0002]q\u0001U;terminal.024438.df-mnt-configuration-lotsys.df\_complex-usedGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000GA^ \u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002a.\u0000\u0000\u0000[\x80\u0002]q\u0001U\<terminal.028022.sensors-w83627uhg-isa-0290.temperature-temp2GA\xD8\xE6\xDD\xC3@\u0000\u0000G@F\x80\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002a.\u0000\u0000\u0000\x87\x80\u0002]q\u0001(U-terminal.029228.top.\_usr\_sbin\_rsyslogd.topcpuGA\xD8\xE6ݴ\u0000\u0000\u0000G\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002U\"terminal.029228.cpu.percent-activeGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G@\<G\xED\u0012th'\x86\x86q\u0003e.\u0000\u0000\u0000H\x80\u0002]q\u0001U)terminal.019329.top.{chromium-bin}.topmemGA\xD8\xE6\xDDÀ\u0000\u0000G@(\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002a.\u0000\u0000\u0000\x87\x80\u0002]q\u0001(U#terminal.020581.top.collectd.topcpuGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002U,terminal.022093.top.{cdu\_web\_server.}.topmemGA\xD8\xE6\xDD\xC2\xC0\u0000\u0000G?\xF0\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0003e.\u0000\u0000\u0000[\x80\u0002]q\u0001U\<terminal.023309.sensors-w83627uhg-isa-0290.temperature-temp2GA\xD8\xE6\xDD\xC3@\u0000\u0000G@G@\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002a.\u0000\u0000\u0000X\x80\u0002]q\u0001U9terminal.025496.top.\_usr\_lib\_chromium\_chromium-bin.topmemGA\xD8\xE6ݴ\u0000\u0000\u0000G@C\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002a.\u0000\u0000\u0000l\x80\u0002]q\u0001(U\u001ATC.RDL027260.bcr.fwversionGA\xD8\xE6ݥ@\u0000\u0000GA|\xF2\xA1p\u0000\u0000\u0000\x86\x86q\u0002U\u001ATC.RDL027260.bcr.fwversionGA\xD8\xE6ݴ\x80\u0000\u0000GA|\xF2\xA1p\u0000\u0000\u0000\x86\x86q\u0003e.\u0000\u0000\u0000\x97\x80\u0002]q\u0001(U-terminal.025523.top.\_usr\_sbin\_rsyslogd.topmemGA\xD8\xE6ݴ\u0000\u0000\u0000G@\u0014\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002U2terminal.024269.top.\_opt\_app\_LT\_application.topcpuGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G@C\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0003e.\u0000\u0000\u0000I\x80\u0002]q\u0001U_terminal.019950.df-data.percent\_bytes-usedGA\xD8\xE6\xDD\xC3@\u0000\u0000G?\xE4.J\xFF\xFF\xFF\xFE\x86\x86q\u0002a.\u0000\u0000\u0000W\x80\u0002]q\u0001U8terminal.029228.sensors-w83627uhg-isa-0290.fanspeed-fan1GA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G@\x9F`\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002a.\u0000\u0000\u0000F\x80\u0002]q\u0001U'terminal.029600.memory.percent-bufferedGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G@\u0004:\xAB\xF8\xB4\xD8\f\x86\x86q\u0002a.\u0000\u0000\u0000D\x80\u0002]q\u0001U%terminal.028841.top.\_usr\_bin\_X.topcpuGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G@\u0000\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002a.\u0000\u0000\u0000\x8C\x80\u0002]q\u0001(U\"terminal.028958.top.COMMAND.topcpuGA\xD8\xE6\xDD\xC3@\u0000\u0000G\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002U2terminal.028958.top.\_opt\_app\_LT\_application.topmemGA\xD8\xE6\xDD\xC3@\u0000\u0000G@P\x80\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0003e.\u0000\u0000\u0000X\x80\u0002]q\u0001U9terminal.022285.top.\_usr\_lib\_chromium\_chromium-bin.topcpuGA\xD8\xE6ݴ\u0000\u0000\u0000G@3\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002a.\u0000\u0000\u0000Ā\u0002]q\u0001(U#terminal.027524.top.collectd.topmemGA\xD8\xE6ݴ\u0000\u0000\u0000G@(\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002U&terminal.027524.top..\_pwedwnmgr.topcpuGA\xD8\xE6ݴ\u0000\u0000\u0000G\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0003U+terminal.027524.interface-eth0.if\_octets.rxGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000GA9\u0018\xD6\u0000\u0000\u0000\u0000\x86\x86q\u0004e.\u0000\u0000\u0000\xE6\x80\u0002]q\u0001(U8terminal.029600.sensors-w83627uhg-isa-0290.fanspeed-fan2GA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G@\xA3b\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002U&terminal.028949.top..\_pweuplmgr.topmemGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G@\u0000\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0003U8terminal.023398.sensors-w83627uhg-isa-0290.fanspeed-fan2GA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G@\xA3\xF8\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0004e.\u0000\u0000\u0000G\x80\u0002]q\u0001U(terminal.023119.memory.percent-slab\_reclGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G?\xE7\x8B\xD1\xDBHg\xA6\x86\x86q\u0002a.\u0000\u0000\u0000D\x80\u0002]q\u0001U%terminal.021456.memory.percent-cachedGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G@E\xC2\xDE\u0015\xB9J\u0004\x86\x86q\u0002a.\u0000\u0000\u0000ɀ\u0002]q\u0001(U%terminal.028022.top.\_usr\_bin\_X.topcpuGA\xD8\xE6\xDD\xC3@\u0000\u0000G@\u0000\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002U\"terminal.028022.top.COMMAND.topmemGA\xD8\xE6\xDD\xC3@\u0000\u0000G\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0003U2terminal.028022.top.\_opt\_app\_LT\_application.topcpuGA\xD8\xE6\xDD\xC3@\u0000\u0000G@\u0018\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0004e.\u0000\u0000\u0000L\x80\u0002]q\u0001U-terminal.026482.top.\_usr\_sbin\_rsyslogd.topcpuGA\xD8\xE6ݴ\u0000\u0000\u0000G\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002a.\u0000\u0000\u0000I\x80\u0002]q\u0001U_terminal.020504.df-data.percent\_bytes-usedGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G?\xC9\f\xA3\xFF\xFF\xFF\xF4\x86\x86q\u0002a.\u0000\u0000\u0000X\x80\u0002]q\u0001U9terminal.025725.sensors-radeon-pci-0008.temperature-temp1GA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G@N\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002a.\u0000\u0000\u0000A\x80\u0002]q\u0001U\"terminal.029228.top.COMMAND.topcpuGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002a.\u0000\u0000\u0000Q\x80\u0002]q\u0001U2terminal.019950.top.\_opt\_app\_LT\_application.topcpuGA\xD8\xE6\xDD\xC3@\u0000\u0000G@\u0010\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002a.\u0000\u0000\u0000\xE0\x80\u0002]q\u0001(U5terminal.025496.df-versions-active.percent\_bytes-usedGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G@A\xF0E\x80\u0000\u0000\u0002\x86\x86q\u0002U\"terminal.025496.top.COMMAND.topcpuGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0003U9terminal.025496.top.\_usr\_lib\_chromium\_chromium-bin.topmemGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G@C\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0004e.\u0000\u0000\u0000B\x80\u0002]q\u0001U#terminal.027866.top..\_pweupl.topcpuGA\xD8\xE6ݴ\u0000\u0000\u0000G\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002a.\u0000\u0000\u0000L\x80\u0002]q\u0001U-terminal.028487.top.\_usr\_sbin\_rsyslogd.topmemGA\xD8\xE6ݴ\u0000\u0000\u0000G@\u0014\u0000\u0000\u0000\u0000\u0000\u0000\x86\x86q\u0002a.\u0000\u0000\u0000I\x80\u0002]q\u0001U_terminal.020580.df-data.percent\_bytes-usedGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G?\xDD\f\xA5\xA0\u0000\u0000\u0005\x86\x86q\u0002a.\u0000\u0000\u0000I\x80\u0002]q\u0001U_terminal.029600.df-data.percent\_bytes-usedGA\xD8\xE6\xDD\xC3\u0000\u0000\u0000G?\xE3", :expected\_charset=\>"UTF-8"}

```auto

```

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [December 15, 2022, 8:49pm UTC](https://discuss.elastic.co/t/tcp-input-receiving-an-encoding-error/321344/2 "2022-12-15T20:49:24Z")

</div>

> [@elrozario](#):
>
> `gsub => ["message", "\\u0018", ""]`

Your message field does not contain \u0018, it contains a UTF-16 CANCEL character. \u0018 is just the representation of that when it is printed in the log.

Given how little the graphite codec [does](https://github.com/logstash-plugins/logstash-codec-graphite/blob/50a3a54c387365168d5fb15689bbc7724c50f350/lib/logstash/codecs/graphite.rb#L58), you might be better off using a line or plain codec so that you can set the encoding correctly using the charset option, and then parse the line yourself.

---

<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:** [January 12, 2023, 8:50pm UTC](https://discuss.elastic.co/t/tcp-input-receiving-an-encoding-error/321344/3 "2023-01-12T20:50:06Z")

</div>

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