# How to parse JSON data in Logstash

**URL:** <https://discuss.elastic.co/t/how-to-parse-json-data-in-logstash/116550>\
**Category:** Logstash\
**Created:** [January 22, 2018, 11:25pm UTC](https://discuss.elastic.co/t/how-to-parse-json-data-in-logstash/116550 "2018-01-22T23:25:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rajkamalkool6](https://avatars.discourse-cdn.com/v4/letter/r/e9c0ed/32.png) [@rajkamalkool6](https://discuss.elastic.co/u/rajkamalkool6)\
**Post date:** [January 22, 2018, 11:25pm UTC](https://discuss.elastic.co/t/how-to-parse-json-data-in-logstash/116550/1 "2018-01-22T23:25:44Z")

</div>

I am parsing a .txt file which have json format values . When I try to parse the file using JSON filter the data is not getting parsed.

**Logstash.config**

```
 input {
    beats{
 		port => 7360
 		codec => "json"
 		}
 }
 
 filter{	
 		json{
 		  source => "message"
 		}
 	 
 }
 
 output{
 	
 		elasticsearch {
 		index => "logstash-json_sample"
 		hosts => ["xxxxxx:9200"]	
 		}
 	
 }

```

**Filebeat.config**

```
filebeat.prospectors:
- input_type: log

  # Paths that should be crawled and fetched. Glob based paths.
  paths:
    - /zzz/sample/ddd/*.txt

  multiline.pattern: ^\[,
  multiline.negate: true
  multiline.match: after

output.logstash:
  hosts: ["xxxxxx:7360"]

```

**Log file**

```
[
    {
        "timestamp": "2018-01-11T20:55:20.373Z",
        "service": "hdfs",
        "command": "listStatus",
        "resource": "/user/share/lib",
        "allowed": true,
        "serviceValues": {
            "src": "/user/share/lib",
            "permissions": null,
            "delegation_token_id": null,
            "dest": null
        }
    },
    {
        "timestamp": "2018-01-11T20:55:11.000Z",
        "service": "imp",
        "command": "USE",
        "resource": "null:atscale",
        "operationText": "USE atscale",
        "allowed": true,
        "serviceValues": {
            "operation_text": "USE atscale",
            "database_name": null,
            "object_type": "DATABASE",
            "privilege": "ANY",
            "status": ""
        }
    },
	......
	.......
	.....
]

```

**_NOTE:_** Log file is huge file Ijust provided the sample

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [January 23, 2018, 10:10am UTC](https://discuss.elastic.co/t/how-to-parse-json-data-in-logstash/116550/2 "2018-01-23T10:10:32Z")

</div>

Comment out your elasticsearch output and add a `stdout { codec => rubydebug }` output so you can easily dump the events coming out of Logstash. What are you currently getting?

---

<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 20, 2018, 10:10am UTC](https://discuss.elastic.co/t/how-to-parse-json-data-in-logstash/116550/3 "2018-02-20T10:10:50Z")

</div>

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