# How to use Grok for JSON parsing

**URL:** <https://discuss.elastic.co/t/how-to-use-grok-for-json-parsing/295794>\
**Category:** Logstash\
**Created:** [January 31, 2022, 2:43am UTC](https://discuss.elastic.co/t/how-to-use-grok-for-json-parsing/295794 "2022-01-31T02:43:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adabi\_Raihan](https://avatars.discourse-cdn.com/v4/letter/a/67e7ee/32.png) [@Adabi\_Raihan](https://discuss.elastic.co/u/Adabi_Raihan)\
**Post date:** [January 31, 2022, 2:43am UTC](https://discuss.elastic.co/t/how-to-use-grok-for-json-parsing/295794/1 "2022-01-31T02:43:20Z")

</div>

Hi,

I want to parse this JSON object to ELK

```auto
{
"Format": "IDEA0",
"ID": "2b03eb1f-fc4c-4f67-94e5-31c9fb32dccc",
"DetectTime": "2022-01-31T08:16:12.600470+07:00",
"EventTime": "2022-01-31T01:23:01.637438+00:00",
"Category": ['Intrusion.Botnet'],
"Confidence": 0.03,
"Note": "C&C channel, destination IP: 192.168.1.24 port: 8007/tcp score: 0.9324",
"Source": [{'IP4': ['192.168.1.25'], 'Type': ['CC']}]
}

```

I've already used this grok to parse it but i think the field won't separate, and get some error that

```auto
input {
        file {
                path => "/home/ubuntu/Downloads/StratosphereLinuxIPS/output/*.json"
                start_position => "beginning"
                sincedb_path => "/dev/null"
        }
}

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

output {
        elasticsearch {
                hosts => ["localhost:9200"]
                index => "test-test"
                user => "***"
                password => "***"
        }
        stdout{}
}

```

Thanks.  
Adabi

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [January 31, 2022, 2:49am UTC](https://discuss.elastic.co/t/how-to-use-grok-for-json-parsing/295794/2 "2022-01-31T02:49:32Z")

</div>

Perhaps take a look at this thread.

> [@Error in parsing Pretty Json Data](https://discuss.elastic.co/t/error-in-parsing-pretty-json-data/293103):
>
> Hi team I have file in json format. [{ "year": 2013, "title": "Rush", "info": { "directors": ["Ron Howard"], "release\_date": "2013-09-02T00:00:00Z", "rating": 8.3, "genres": ["Action", "Biography", "Drama", "Sport"], "image\_url": "http://ia.media-imdb.com/images/M/MV5BMTQyMDE0MTY0OV5BMl5BanBnXkFtZTcwMjI2OTI0OQ@@.\_V1\_SX400\_.jpg", …

---

<div class="post-metadata">

**Author:** ![Adabi\_Raihan](https://avatars.discourse-cdn.com/v4/letter/a/67e7ee/32.png) [@Adabi\_Raihan](https://discuss.elastic.co/u/Adabi_Raihan)\
**Post date:** [January 31, 2022, 4:58am UTC](https://discuss.elastic.co/t/how-to-use-grok-for-json-parsing/295794/3 "2022-01-31T04:58:59Z")

</div>

Hi Stephen,

Thanks for the answer.

Is there any other solution to separate it in the Logstash Pipeline ? so I don't need to run it using the jq command.

it's because I'm countering this error while using the jq command

```auto
Parse error: Invalid numeric literal at line 6, column 31

```

The real problem here is this

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/5/e/5efee4d9f62679c189f7f6f472653c8cd0c2cf94.png)

I want to separate the field (see picture) in kibana but i don't know-how

Thanks.  
Adabi

---

<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 28, 2022, 4:59am UTC](https://discuss.elastic.co/t/how-to-use-grok-for-json-parsing/295794/4 "2022-02-28T04:59:54Z")

</div>

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