# Read JSON fields with filebeat

**URL:** <https://discuss.elastic.co/t/read-json-fields-with-filebeat/179666>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [May 5, 2019, 11:05am UTC](https://discuss.elastic.co/t/read-json-fields-with-filebeat/179666 "2019-05-05T11:05:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leon\_Voerman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leon_voerman/32/45566_2.png) [@Leon\_Voerman](https://discuss.elastic.co/u/Leon_Voerman)\
**Post date:** [May 5, 2019, 11:05am UTC](https://discuss.elastic.co/t/read-json-fields-with-filebeat/179666/1 "2019-05-05T11:05:19Z")

</div>

Hi all,

I'm trying to read the data fields of a JSON message from my anti virus with filebeat, but somehow it keeps showing up as a full message.

It doesn't filter/detect the process.name and hostname and PID either.

Here's a example message I get:

`May 5 10:58:36 app ERAServer[880] ﻿{"event_type":"Threat_Event","ipv4":"192.168.178.221","hostname":"gaming","source_uuid":"5a0ad926-a7e5-4673-967b-21f351135c14","occured":"05-May-2019 10:57:50","severity":"Warning","threat_type":"test file","threat_name":"Eicar","scanner_id":"HTTP filter","scan_id":"virlog.dat","engine_version":"19304 (20190505)","object_type":"file","object_uri":"https://www.eicar.org/download/eicar.com.txt","action_taken":"connection terminated","threat_handled":true,"need_restart":false,"username":"GAMING\\leon","processname":"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe","circumstances":"Event occurred during an attempt to access the web.","hash":"3395856CE81F2B7382DEE72602F798B642F14140"}`

My filebeat config looks like this:

```
filebeat.inputs:
- type: log
  enabled: true
  paths:
    - /var/log/syslog
  json.keys_under_root: true
  json.add_error_key: true
  processors:
     - decode_json_fields:
         fields: ["ipv4", "hostname", "object_type", "object_uri", "action_taken", "thread_name", "username"]
         process_array: false
         max_depth: 1
         target: ""
         overwrite_keys: true

```

It do get an error:  
Error decoding JSON: invalid character 'M' looking for beginning of value

Most likely because it starts reading JSON from the beginning of the line, which is a timestamp, not JSON. But I am clueless on how to filter that out.

Would love some help here. I've been working and searching for a solutions for 2 weeks now.

UPDATE:  
Fixed it using logstash instead.

---

<div class="post-metadata">

**Author:** ![Leon\_Voerman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leon_voerman/32/45566_2.png) [@Leon\_Voerman](https://discuss.elastic.co/u/Leon_Voerman)\
**Post date:** [May 5, 2019, 4:08pm UTC](https://discuss.elastic.co/t/read-json-fields-with-filebeat/179666/2 "2019-05-05T16:08:58Z")

</div>

Never mind, fixed it using logstash instead.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 5, 2019, 11:07pm UTC](https://discuss.elastic.co/t/read-json-fields-with-filebeat/179666/3 "2019-05-05T23:07:02Z")

</div>

I was gunna say that or use the Ingest API in Elasticsearch.

---

<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:** [June 2, 2019, 11:07pm UTC](https://discuss.elastic.co/t/read-json-fields-with-filebeat/179666/4 "2019-06-02T23:07:06Z")

</div>

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