# Logstash parse json file content failed, but ok when enter one line with input plugin

**URL:** https://discuss.elastic.co/t/logstash-parse-json-file-content-failed-but-ok-when-enter-one-line-with-input-plugin/260503
**Category:** Logstash
**Created:** [January 8, 2021, 7:01am UTC](https://discuss.elastic.co/t/logstash-parse-json-file-content-failed-but-ok-when-enter-one-line-with-input-plugin/260503 "2021-01-08T07:01:20Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![bo\_bo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bo_bo/32/67280_2.png) [@bo\_bo](https://discuss.elastic.co/u/bo_bo)
#### Post date: [January 8, 2021, 7:01am UTC](https://discuss.elastic.co/t/logstash-parse-json-file-content-failed-but-ok-when-enter-one-line-with-input-plugin/260503/1 "2021-01-08T07:01:20Z")

</div>

File content is:

> {"#account\_id":"43DDBF5E46FBC68F2B9C395DA7C3443B","#distinct\_id":"205aa1ec49b21576da4ee3beb994f132","#type":"track","#ip":"122.157.17 5.52","#time":"2020-01-06 19:44:54","#event\_name":"TALENT\_CAPTURE","properties":{"role\_uid":1135771889734230,"current\_server":1001,"c reate\_server":1001,"channel":"32","role\_name":"[æ¡\<83\>]é¬¼é­\<85\>","role\_create\_time":"2019-11-02 12:15:21","total\_rmb":0,"role\_level" :100,"unionid\_uid":2254052399020837219,"unionid\_name":"å\<90\>\<8d\>æ\<89\>¬å\<9b\>\<9b\>æµ·","ad":"","device":"205aa1ec49b21576da4ee3beb994f13 2","os":"1","os\_version":"Android OS 5.1 / API-22 (LMY47O/J5008ZMS1ARG1)","role\_type":0,"fighting":256025,"pay":false,"exp":127210,"l evel":100,"money":0,"gift\_money":0,"gold":17627,"daohang":18683,"contribution":8394,"achieve":1240,"vigour":16,"country":"0","dungeon \_ticket":0,"friend\_point":10,"account\_time":"2019-11-02 12:13:54","idfa":"","TALENT\_CAPTURE\_talent\_tree":"é\<98\>´é\<98\>³","TALENT\_CAPTU RE\_talent\_list":"»ù´¡Ìì¸³£¨ÒõÑô£©","TALENT\_CAPTURE\_talent\_name":"»ù´¡·ÀÓù","TALENT\_CAPTURE\_talent\_level":5,"TALENT\_CAPTURE\_tree\_level ":3}}  
> {"#account\_id":"84576032","#distinct\_id":"95099e577eff0ae2d7d6b8db6eb664d2","#type":"track","#ip":"103.228.209.175","#time":"2020-01-06 18:49:32","#event\_name":"TALENT\_CAPTURE","properties":{"role\_uid":1135770815430664,"current\_server":1001,"create\_server":1001,"channel":"134","role\_name":"é\<87\>\<8e\>æ\<8d\>\<8f\>å§\<91\>è®¡è´¼","role\_create\_time":"2019-09-12 10:25:25","total\_rmb":5771,"role\_level":100,"unionid\_uid":2254052399020837219,"unionid\_name":"å\<90\>\<8d\>æ\<89\>¬å\<9b\>\<9b\>æµ·","ad":"","device":"95099e577eff0ae2d7d6b8db6eb664d2","os":"1","os\_version":"Android OS 10 / API-29 (HUAWEIPCT-AL10/10.0.0.187C00)","role\_type":0,"fighting":578437,"pay":true,"exp":127210,"level":100,"money":0,"gift\_money":13,"gold":59812,"daohang":18803,"contribution":349,"achieve":1405,"vigour":33,"country":"0","dungeon\_ticket":0,"friend\_point":4860,"account\_time":"2019-09-12 10:16:43","idfa":"","TALENT\_CAPTURE\_talent\_tree":"å\<91\>½","TALENT\_CAPTURE\_talent\_list":"»ù´¡Ìì¸³£¨Ãü£©","TALENT\_CAPTURE\_talent\_name":"¸ß¼¶ÉúÃü","TALENT\_CAPTURE\_talent\_level":5,"TALENT\_CAPTURE\_tree\_level":4}}  
> {"#account\_id":"84576032","#distinct\_id":"95099e577eff0ae2d7d6b8db6eb664d2","#type":"track","#ip":"103.228.209.175","#time":"2020-01-06 18:49:32","#event\_name":"TALENT\_CAPTURE","properties":{"role\_uid":1135770815430664,"current\_server":1001,"create\_server":1001,"channel":"134","role\_name":"é\<87\>\<8e\>æ\<8d\>\<8f\>å§\<91\>è®¡è´¼","role\_create\_time":"2019-09-12 10:25:25","total\_rmb":5771,"role\_level":100,"unionid\_uid":2254052399020837219,"unionid\_name":"å\<90\>\<8d\>æ\<89\>¬å\<9b\>\<9b\>æµ·","ad":"","device":"95099e577eff0ae2d7d6b8db6eb664d2","os":"1","os\_version":"Android OS 10 / API-29 (HUAWEIPCT-AL10/10.0.0.187C00)","role\_type":0,"fighting":578437,"pay":true,"exp":127210,"level":100,"money":0,"gift\_money":13,"gold":59812,"daohang":18803,"contribution":349,"achieve":1405,"vigour":33,"country":"0","dungeon\_ticket":0,"friend\_point":4860,"account\_time":"2019-09-12 10:16:43","idfa":"","TALENT\_CAPTURE\_talent\_tree":"å\<91\>½","TALENT\_CAPTURE\_talent\_list":"»ù´¡Ìì¸³£¨Ãü£©","TALENT\_CAPTURE\_talent\_name":"Ã°ÏÕÑµÁ·","TALENT\_CAPTURE\_talent\_level":4,"TALENT\_CAPTURE\_tree\_level":4}}

logstash version is: **7.6.0**  
my logstash configration file is:

```auto
    input {
      file {
        path => "/data/datacenter/td_data/server_*/*"
        codec => "json"
        start_position => "beginning"
        sincedb_path => "/root/.sincedb_7ffa64810fcb36c4ee4110e93c729542"
        sincedb_write_interval => 10
        codec => {
             charset => "UTF-8" 
        }
      }
    }

    filter {
        json {
          source => "message"
        }
        date {
            match => ["#time", "yyyy-MM-dd HH:mm:ss"]
        }
        if [path] =~ /ONLINE_NUM_[0-9]/ {
            mutate {
                add_field => ["[@metadata][index_name]" , "ONLINE_NUM" ]
            }
        } else if [path] =~ /TALENT_[0-9]/ {
            mutate {
                add_field => ["[@metadata][index_name]" , "TALENT" ]
            }
        }
        else {
            mutate {
                add_field => ["[@metadata][index_name]" , "TALENTxxxx" ]
            }
        }
    }

    output {
        mongodb {
            # codec => line {format => "%{message}"}
            uri => "mongodb://172.19.209.83:28017"
            database => "doujiang"
            collection => "%{[@metadata][index_name]}"
        }
        stdout { codec => rubydebug }
    }

```

when i started logstash, some error happend, but when i use input plugin, enter single whole line each time, it works successfully,  
what's wrong with my configration files?  
the error infomation is:

> [2021-01-08T15:00:02,241][WARN][logstash.filters.json][main] Error parsing json {:source=\>"message", :raw=\>"{\"#account\_id\":\"171355430\",\"#distinct\_id\":\"38549fe83fc6c431cde37148c49beb2d\",\"#type\":\"track\",\"#ip\":\"223.104.63.4\",\"#time\":\"2020-01-06 09:21:20\",\"#event\_name\":\"TALENT\_CAPTURE\",\"properties\":{\"role\_uid\":1135776184197152,\"current\_server\":1003,\"create\_server\":1003,\"channel\":\"15\",\"role\_name\":\"长安危玄静\",\"role\_create\_time\":\"2019-09-21 09:36:08\",\"total\_rmb\":5980,\"role\_level\":100,\"unionid\_uid\":2278822232313014479,\"unionid\_name\":\"诗情画意\",\"ad\":\"\",\"device\":\"38549fe83fc6c431cde37148c49beb2d\",\"os\":\"1\",\"os\_version\":\"Android OS 6.0 / API-23 (MRA58K/V10.2.2.0.MBFCNXM)\",\"role\_type\":0,\"fighting\":464710,\"pay\":true,\"exp\":127210,\"level\":100,\"money\":0,\"gift\_money\":805,\"gold\":13275,\"daohang\":18803,\"contribution\":385,\"achieve\":1370,\"vigour\":50,\"country\":\"0\",\"dungeon\_ticket\":3,\"friend\_point\":450,\"account\_time\":\"2019-09-21 09:34:02\",\"idfa\":\"\",\"TALENT\_CAPTURE\_talent\_tree\":\"阴阳\",\"TALENT\_CAPTURE\_talent\_list\":\"\xBD\xF8\xBD\xD7\xCC츳\xA3\xA8\xD2\xF5\xD1\xF4\xA3\xA9\",\"TALENT\_CAPTURE\_talent\_name\":\"\xBB\xF9\xB4\xA1\xB7\xC0\xD3\xF9\",\"TALENT\_CAPTURE\_talent\_level\":10,\"TALENT\_CAPTURE\_tree\_level\":10}}", :exception=\>#\<LogStash::Json::ParserError: Unexpected character ('' (code 92)): was expecting double-quote to start field name  
> at [Source: (byte)"{"#account\_id":"171355430","#distinct\_id":"38549fe83fc6c431cde37148c49beb2d","#type":"track","#ip":"223.104.63.4","#time":"2020-01-06 09:21:20","#event\_name":"TALENT\_CAPTURE","properties":{"role\_uid":1135776184197152,"current\_server":1003,"create\_server":1003,"channel":"15","role\_name":"长安危玄静","role\_create\_time":"2019-09-21 09:36:08","total\_rmb":5980,"role\_level":100,"unionid\_uid":2278822232313014479,"unionid\_name":"诗情画意",""[truncated 720 bytes]; line: 1, column: 3]\>}  
> Blockquote  
> please help me, thank you

---

<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: [February 5, 2021, 7:01am UTC](https://discuss.elastic.co/t/logstash-parse-json-file-content-failed-but-ok-when-enter-one-line-with-input-plugin/260503/2 "2021-02-05T07:01:25Z")

</div>

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