# Json file with logstash

**URL:** <https://discuss.elastic.co/t/json-file-with-logstash/183971>\
**Category:** Logstash\
**Created:** [June 3, 2019, 1:20pm UTC](https://discuss.elastic.co/t/json-file-with-logstash/183971 "2019-06-03T13:20:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![decodeit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/decodeit/32/46023_2.png) [@decodeit](https://discuss.elastic.co/u/decodeit)\
**Post date:** [June 3, 2019, 1:20pm UTC](https://discuss.elastic.co/t/json-file-with-logstash/183971/1 "2019-06-03T13:20:01Z")

</div>

I converted a csv file to a json file. How to read this file with logstash and put in elasticsearch. I don't see any error. My json file looks like this:

`[{"LOR": "LOR ", "CGPA": "CGPA", "TOEFL Score": "TOEFL Score", "GRE Score": "GRE Score", "Serial No": "Serial No", "SOP": "SOP", "Chance of Admit": "Chance of Admit ", "University Rating": "University Rating", "Research": "Research"}, {"LOR": "4.5", "CGPA": "9.65", "TOEFL Score": "118", "GRE Score": "337", "Serial No": "1", "SOP": "4.5", "Chance of Admit": "0.82", "University Rating": "4", "Research": "1"}, {"LOR": "4.5", "CGPA": "8.87", "TOEFL Score": "107", "GRE Score": "324", "Serial No": "2", "SOP": "4", "Chance of Admit": "0.76", "University Rating": "4", "Research": "1"},`

There is more.

my logstash config file is like this:

```
`input {
file{
	codec =>json
    
	path => "/home/abhinavkumar.gurung/Applications/csv/devian/data/file.json"
	start_position => "beginning"
	sincedb_path => "/dev/null"
}

```

}  
filter {  
json{  
source =\>"message"  
}  
mutate{  
remove\_field =\> ["@version","host"]  
}  
}  
output {  
elasticsearch {  
hosts =\> ["elasticsearch:9200"]  
user =\> elastic  
password =\> changeme  
index =\> "markers"  
}  
stdout {  
codec =\> rubydebug  
}  
}`

---

<div class="post-metadata">

**Author:** ![pastechecker](https://avatars.discourse-cdn.com/v4/letter/p/0ea827/32.png) [@pastechecker](https://discuss.elastic.co/u/pastechecker)\
**Post date:** [June 4, 2019, 9:24am UTC](https://discuss.elastic.co/t/json-file-with-logstash/183971/2 "2019-06-04T09:24:06Z")

</div>

Do you see anything in the rubydebug that you are using?

---

<div class="post-metadata">

**Author:** ![sjabiulla](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sjabiulla/32/48429_2.png) [@sjabiulla](https://discuss.elastic.co/u/sjabiulla)\
**Post date:** [June 4, 2019, 11:04am UTC](https://discuss.elastic.co/t/json-file-with-logstash/183971/3 "2019-06-04T11:04:07Z")

</div>

I have tried with minimal config and everything looks fine on my side. Can you please check and compare your config's with this .

A sample json file with the below content.

```
{"menu": {"id": "file","value": "File","popup": {"menuitem": [{"value": "New", "onclick": "CreateNewDoc()"},{"value": "Open", "onclick": "OpenDoc()"},{"value": "Close", "onclick": "CloseDoc()"}]}}}

```

My Logstash conf file :

```
input {
    file {
        path => "path-to-file/sample.json"
        start_position => "beginning"
	}
}
filter{
	json{
		source => "message"
	}
}
output
{
	elasticsearch{
		hosts => ["localhost:9200"]
		index => ["test-file-%{+YYYY.MM.dd}"]
	}
	stdout { codec => rubydebug }
}

```

Here is my Elasticsearch output.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/8/f/8f5cc8e8f51b9d890c4c09f6ed605661e4024f0f.png)

> [@decodeit](#):
>
> I converted a csv file to a json file

I'm not sure why you want to convert csv to json , because Logstash has csv filter too. Check the below link once to understand how to use csv filter.

> **[Csv filter plugin | Logstash Reference \[8.11\] | Elastic](https://www.elastic.co/guide/en/logstash/current/plugins-filters-csv.html)**

---

<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 2, 2019, 11:04am UTC](https://discuss.elastic.co/t/json-file-with-logstash/183971/4 "2019-07-02T11:04:10Z")

</div>

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