# Logstash json input {}, “” filter

**URL:** <https://discuss.elastic.co/t/logstash-json-input-filter/179862>\
**Category:** Logstash\
**Created:** [May 7, 2019, 12:28am UTC](https://discuss.elastic.co/t/logstash-json-input-filter/179862 "2019-05-07T00:28:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![xodn0812](https://avatars.discourse-cdn.com/v4/letter/x/c5a1d2/32.png) [@xodn0812](https://discuss.elastic.co/u/xodn0812)\
**Post date:** [May 7, 2019, 12:28am UTC](https://discuss.elastic.co/t/logstash-json-input-filter/179862/1 "2019-05-07T00:28:43Z")

</div>

I want to get a json-style event that contains "" or {}. However, if "" and {} are included, filtering is not done properly.

Is there no way??

msg:  
`{"key1":"val1","key2":"val2", "key3": "asfqwe12\"wef\"qw{asd}e213524" }`

config:

> ```
> filter {
> json{
> source => "message"
> }
> mutate {
> gsub => ["message", "\n", "\\n"]
> gsub => ["message", "\t", ""]
> }
> json{
> source => "message"
> }
> mutate {
> gsub => [ "message", "\\n", "
> " ]
> }
> }
> 
> ```

---

<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:** [May 7, 2019, 2:19pm UTC](https://discuss.elastic.co/t/logstash-json-input-filter/179862/2 "2019-05-07T14:19:31Z")

</div>

> [@xodn0812](#):
>
> filtering is not done properly

What does that mean?

Why do you have two json filters?

---

<div class="post-metadata">

**Author:** ![xodn0812](https://avatars.discourse-cdn.com/v4/letter/x/c5a1d2/32.png) [@xodn0812](https://discuss.elastic.co/u/xodn0812)\
**Post date:** [May 8, 2019, 6:09am UTC](https://discuss.elastic.co/t/logstash-json-input-filter/179862/3 "2019-05-08T06:09:12Z")

</div>

1. I tried twice for \ n or \ t because of json filtering failure. can delete the top json filter.

2. 

```
"key3": "asfqwe12 \" wef \ "qw {asd} e213524"

```

If log contains {} ""  
like above, json filtering fails.  
I want to solve this.

I just want to get it as a regular expression rather than a json format.

---

<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:** [May 8, 2019, 1:51pm UTC](https://discuss.elastic.co/t/logstash-json-input-filter/179862/4 "2019-05-08T13:51:51Z")

</div>

I am unable to reproduce the issue

```
input { generator { count => 1 message => ' {"key1":"val1","key2":"val2", "key3": "asfqwe12\"wef\"qw{asd}e213524" } ' } }

filter { json { source => "message" } }

output { stdout { codec => rubydebug { metadata => false } } }

```

produces this

```
      "key3" => "asfqwe12\"wef\"qw{asd}e213524",
   "message" => " {\"key1\":\"val1\",\"key2\":\"val2\", \"key3\": \"asfqwe12\\\"wef\\\"qw{asd}e213524\" } ",
      "key1" => "val1",
      "key2" => "val2"
```

---

<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:** [June 5, 2019, 1:51pm UTC](https://discuss.elastic.co/t/logstash-json-input-filter/179862/5 "2019-06-05T13:51:51Z")

</div>

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