# Logstash & JSON

**URL:** https://discuss.elastic.co/t/logstash-json/72377
**Category:** Logstash
**Created:** [January 21, 2017, 10:00pm UTC](https://discuss.elastic.co/t/logstash-json/72377 "2017-01-21T22:00:36Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![alexus](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexus/32/12696_2.png) [@alexus](https://discuss.elastic.co/u/alexus)
#### Post date: [January 21, 2017, 10:00pm UTC](https://discuss.elastic.co/t/logstash-json/72377/1 "2017-01-21T22:00:36Z")

</div>

I'm trying to configure Logstash with JSON.

logstash configuration:

```
root@596f81c45ea4:~# cat /etc/logstash/conf.d/* | grep -v \#

input {
  gelf { codec => "json" }
}

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

output {
  elasticsearch { hosts => ["0:9200"] }
}
root@596f81c45ea4:~# 

```

input:

> {"level":"info","ts":"2017-01-21T21:53:21+0000","X":"Y","recordtype":"Z","action":"SET","start":"2017-01-21T21:53:21+0000"}

/var/log/logstash/logstash-plain.log:

> [2017-01-21T21:36:32,584][WARN][logstash.outputs.elasticsearch] Failed action. {:status=\>400, :action=\>["index", {:\_id=\>nil, :\_index=\>"logstash-2017.01.21", :\_type=\>"logs", :\_routing=\>nil}, 2017-01-21T21:36:32.178Z X {"level":"info","ts":"2017-01-21T21:36:32+0000","msg":"Connected to Elastic node","name":"y3QUVEG","version":"5.1.1","code":200}], :response=\>{"index"=\>{"\_index"=\>"logstash-2017.01.21", "\_type"=\>"logs", "\_id"=\>"AVnC9Zktif7z\_nOdo0lI", "status"=\>400, "error"=\>{"type"=\>"mapper\_parsing\_exception", "reason"=\>"failed to parse [level]", "caused\_by"=\>{"type"=\>"number\_format\_exception", "reason"=\>"For input string: "info""}}}}}

Please advise.

---

<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 22, 2017, 1:40pm UTC](https://discuss.elastic.co/t/logstash-json/72377/2 "2017-01-22T13:40:48Z")

</div>

It looks like ES has mapped the `level` field as an integer but you're trying to feed it a string. Check the mappings of the index. If that's the case you need to reindex. Since you're just starting out maybe the easiest option is to just delete the index and start over?

---

<div class="post-metadata">

### Author: ![alexus](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexus/32/12696_2.png) [@alexus](https://discuss.elastic.co/u/alexus)
#### Post date: [January 23, 2017, 5:45pm UTC](https://discuss.elastic.co/t/logstash-json/72377/3 "2017-01-23T17:45:02Z")

</div>

that did the job, thank you!

---

<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, 2017, 5:45pm UTC](https://discuss.elastic.co/t/logstash-json/72377/4 "2017-02-20T17:45:08Z")

</div>

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