# Mixed log with timestamp and json data

**URL:** <https://discuss.elastic.co/t/mixed-log-with-timestamp-and-json-data/27456>\
**Category:** Logstash\
**Created:** [August 16, 2015, 4:06pm UTC](https://discuss.elastic.co/t/mixed-log-with-timestamp-and-json-data/27456 "2015-08-16T16:06:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![muhammadn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/muhammadn/32/4205_2.png) [@muhammadn](https://discuss.elastic.co/u/muhammadn)\
**Post date:** [August 16, 2015, 4:06pm UTC](https://discuss.elastic.co/t/mixed-log-with-timestamp-and-json-data/27456/1 "2015-08-16T16:06:11Z")

</div>

I also have a mixed json data with the timestamp first which i followed with the following code:

````auto
   grok{
      match => ["message", "%{DATESTAMP} %{GREEDYDATA:message}"]
      overwrite => ["message"]
   }
   json{
      source => "message"
      remove_field => ["message"]
   }
}

where %{DATESTAMP} is the timestamp at the beginning of the message and %{GREEDYDATA:message} is the json data

Results is partially working where the timestamp removed but json cannot be parsed:
```"message": "{\\\"id\\\":\\\"55d09c10f2aee2000133673a\\\",\\\"fingerprintjs_id\\\":\\\"\\\",\\\"email\\\":\\\"\\\",\\\"app_key\\\":\\\"ZSp-0vi8_0yRDY66bW--dg\\\",\\\"referrer\\\":\\\"http://www.domain.com/\\\",\\\"client_timestamp\\\":\\\"2015-08-16T14:20:04.709Z\\\",\\\"page_view_client_key\\\":\\\"b9d235da2011439734804706\\\",\\\"user_agent\\\":\\\"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.155 Safari/537.36\\\",\\\"keywords\\\":\\\"\\\",\\\"description\\\":\\\"Police, military and search teams would check the area in Oksibil district where there had been reports of the crash.\\\",\\\"title\\\":\\\"Missing Indonesian plane with 54 crashed, report residents - Khaleej Times\\\",\\\"uid\\\":\\\"55d09c10f2aee2000133673b\\\",\\\"session_id\\\":\\\"55d09c10f2aee2000133673c\\\",\\\"url\\\":\\\"http://www.domain.com/international/rest-of-asia/missing-indonesian-plane-with-54-crashed-report-residents\\\",\\\"ip\\\":\\\"83.110.196.21\\\",\\\"received_at\\\":\\\"2015-08-16T14:20:00.802Z\\\"}\\n\",\"stream\":\"stdout\",\"time\":\"2015-08-16T14:20:00.802862057Z\"}",```

but it still shows:
`[0] "_jsonparsefailure"`

I think it is not normal with so many escape \\\ characters in json? (Note: I am not using json codec but json filter only with grok)
````

---

<div class="post-metadata">

**Author:** ![Joshua\_Rich](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joshua_rich/32/44953_2.png) [@Joshua\_Rich](https://discuss.elastic.co/u/Joshua_Rich)\
**Post date:** [August 16, 2015, 11:14pm UTC](https://discuss.elastic.co/t/mixed-log-with-timestamp-and-json-data/27456/2 "2015-08-16T23:14:02Z")

</div>

Try adding a `mutate` filter before the `json` filter and use the _gsub_ parameter to strip out those backslashes from the JSON. Something like:

```auto
mutate {
  gsub => ["message", "[\\]", "" ]
}

```

---

<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:** [July 6, 2017, 5:31am UTC](https://discuss.elastic.co/t/mixed-log-with-timestamp-and-json-data/27456/3 "2017-07-06T05:31:51Z")

</div>


