# How to read json data using filebeat and preserve attribute names in Logstash

**URL:** <https://discuss.elastic.co/t/how-to-read-json-data-using-filebeat-and-preserve-attribute-names-in-logstash/148115>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [September 11, 2018, 12:11pm UTC](https://discuss.elastic.co/t/how-to-read-json-data-using-filebeat-and-preserve-attribute-names-in-logstash/148115 "2018-09-11T12:11:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![elasticheart](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elasticheart/32/65189_2.png) [@elasticheart](https://discuss.elastic.co/u/elasticheart)\
**Post date:** [September 11, 2018, 12:11pm UTC](https://discuss.elastic.co/t/how-to-read-json-data-using-filebeat-and-preserve-attribute-names-in-logstash/148115/1 "2018-09-11T12:11:14Z")

</div>

Hi all,

I have single line log files (`\n` delimiter) in which logs are entered in json format like;

```
{"f1":"data1","timestamp":"2018-09-10T12:33:15.878+0000","f2":"data2","f3":1234,"f4":"data4","server":"192.168.0.1","f5":"data5","f6":"1","f7":"data7","f8":"data8","f9":"data9","f10":false}

```

I want to publish this to kafka, and fetch using logstash, and then insert into elasticsearch. I want same attribute names in elasticsearch. How can I do this in filebeat?

Thank you.

---

<div class="post-metadata">

**Author:** ![pierhugues](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pierhugues/32/48383_2.png) [@pierhugues](https://discuss.elastic.co/u/pierhugues)\
**Post date:** [September 11, 2018, 2:48pm UTC](https://discuss.elastic.co/t/how-to-read-json-data-using-filebeat-and-preserve-attribute-names-in-logstash/148115/2 "2018-09-11T14:48:50Z")

</div>

@elasticheart Are you decoding the JSON event in Filebeat? I don't see your configuration, but Filebeat log input has options to parse JSON events see the documentation at [https://www.elastic.co/guide/en/beats/filebeat/master/filebeat-input-log.html#filebeat-input-log-config-json](https://www.elastic.co/guide/en/beats/filebeat/master/filebeat-input-log.html#filebeat-input-log-config-json)

---

<div class="post-metadata">

**Author:** ![elasticheart](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elasticheart/32/65189_2.png) [@elasticheart](https://discuss.elastic.co/u/elasticheart)\
**Post date:** [September 12, 2018, 4:55am UTC](https://discuss.elastic.co/t/how-to-read-json-data-using-filebeat-and-preserve-attribute-names-in-logstash/148115/3 "2018-09-12T04:55:22Z")

</div>

hi @pierhugues my current filebeat configuration is as below;

```
filebeat.inputs:
- type: log
  enabled: true
  paths:
    - /logs/sample1.log

output.kafka:
  enabled: true
  hosts: ["192.168.0.1:9092","192.168.0.1:9093","192.168.0.1:9094"]
  topic: testLogs1 

```

and I am using JSON filter in Logstash like;

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

```

This works just fine, but is there any other easy/simpler way to achieve this, so that I can avoid filter in Logstash?

---

<div class="post-metadata">

**Author:** ![pierhugues](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pierhugues/32/48383_2.png) [@pierhugues](https://discuss.elastic.co/u/pierhugues)\
**Post date:** [September 12, 2018, 12:10pm UTC](https://discuss.elastic.co/t/how-to-read-json-data-using-filebeat-and-preserve-attribute-names-in-logstash/148115/4 "2018-09-12T12:10:53Z")

</div>

Yes, you can do all the parsing in Filebeat, I've linked the [documentation](https://www.elastic.co/guide/en/beats/filebeat/master/filebeat-input-log.html#filebeat-input-log-config-json) in my previous reply, but you can also take a look at this (blog post]([https://www.elastic.co/blog/structured-logging-filebeat](https://www.elastic.co/blog/structured-logging-filebeat)) which give you a bit more details.

---

<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:** [October 10, 2018, 12:10pm UTC](https://discuss.elastic.co/t/how-to-read-json-data-using-filebeat-and-preserve-attribute-names-in-logstash/148115/5 "2018-10-10T12:10:55Z")

</div>

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