# Logstash file for parsing JSON data

**URL:** <https://discuss.elastic.co/t/logstash-file-for-parsing-json-data/88570>\
**Category:** Logstash\
**Created:** [June 7, 2017, 11:51am UTC](https://discuss.elastic.co/t/logstash-file-for-parsing-json-data/88570 "2017-06-07T11:51:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![patil-akshay](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/patil-akshay/32/15295_2.png) [@patil-akshay](https://discuss.elastic.co/u/patil-akshay)\
**Post date:** [June 7, 2017, 11:51am UTC](https://discuss.elastic.co/t/logstash-file-for-parsing-json-data/88570/1 "2017-06-07T11:51:19Z")

</div>

I want to parse the below-given JSON data through logstash and load it to the KIbana

Data

{"PhoneNumber":{"0":27817768541},"TimeStamp":{"0":1471433451000},"ncalls":{"0":20}}

can anyone help me with the logstash config file?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [June 7, 2017, 12:30pm UTC](https://discuss.elastic.co/t/logstash-file-for-parsing-json-data/88570/2 "2017-06-07T12:30:21Z")

</div>

What have you tried so far?

---

<div class="post-metadata">

**Author:** ![patil-akshay](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/patil-akshay/32/15295_2.png) [@patil-akshay](https://discuss.elastic.co/u/patil-akshay)\
**Post date:** [June 7, 2017, 12:31pm UTC](https://discuss.elastic.co/t/logstash-file-for-parsing-json-data/88570/3 "2017-06-07T12:31:44Z")

</div>

input {  
file {  
start\_position =\> beginning  
path =\> ["C:/Users/akshay.patil/Desktop/test.log"]  
codec =\> "json"  
}  
}

filter {  
grok {  
match =\> ["message", "[%{WORD}:%{LOGLEVEL}] %{TIMESTAMP\_ISO8601:tstamp} :: %{GREEDYDATA:msg}"]  
}  
json{  
source =\> "message"  
target =\> "parsedJson"  
}  
mutate {  
add\_field =\> {  
"PhoneNumber" =\> "%{[parsedJson][PhoneNumber]}"  
"TimeStamp" =\> "%{[parsedJson][TimeStamp]}"  
"NumberOfCalls" =\> "%{[parsedJson][ncalls]}"  
}  
}   
}

output {  
stdout { codec =\> rubydebug }  
elasticsearch {  
hosts =\> ["localhost:9200"]  
index =\> "logstash-%{+YYYY.MM.dd}"  
}  
}

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [June 7, 2017, 12:34pm UTC](https://discuss.elastic.co/t/logstash-file-for-parsing-json-data/88570/4 "2017-06-07T12:34:15Z")

</div>

What does a full line in the file you are processing look like?

The recommended way to create a config is to remove the Elasticsearch output and just output to stdout, then start with a minimal config, e.g. file input with json codec, and inspect the result. Then add filter after filter until complete, while continuously inspecting how the format of the data changes.

---

<div class="post-metadata">

**Author:** ![patil-akshay](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/patil-akshay/32/15295_2.png) [@patil-akshay](https://discuss.elastic.co/u/patil-akshay)\
**Post date:** [June 8, 2017, 11:34am UTC](https://discuss.elastic.co/t/logstash-file-for-parsing-json-data/88570/5 "2017-06-08T11:34:49Z")

</div>

How will the index get created?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [June 8, 2017, 11:42am UTC](https://discuss.elastic.co/t/logstash-file-for-parsing-json-data/88570/6 "2017-06-08T11:42:25Z")

</div>

Once you have completed the configuration and the events look like they should, you switch from the stdout plugin to the elasticsearch plugin.

---

<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, 11:42am UTC](https://discuss.elastic.co/t/logstash-file-for-parsing-json-data/88570/7 "2017-07-06T11:42:28Z")

</div>

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