# Target field in ndjson

**URL:** <https://discuss.elastic.co/t/target-field-in-ndjson/324014>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [January 26, 2023, 11:07am UTC](https://discuss.elastic.co/t/target-field-in-ndjson/324014 "2023-01-26T11:07:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ddoroshenko](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@ddoroshenko](https://discuss.elastic.co/u/ddoroshenko)\
**Post date:** [January 26, 2023, 11:07am UTC](https://discuss.elastic.co/t/target-field-in-ndjson/324014/1 "2023-01-26T11:07:54Z")

</div>

Hi!

I have a log file with json records like

```auto
{
  "request": {
    "foo": "bar"
  },
  "response": {
    "foo": "bar"
  }
}

```

and the following configuration for filebeat

```auto
- type: filestream
  paths:
    - /path/to/file
  tags: ["tags"]
  fields_under_root: true
  fields:
    field1: value1
  parsers:
    - ndjson:
        target: root
        overwrite_keys: true
        expand_keys: true

```

So I want to see the parsed fields like `root.request.foo` and `root.response.foo` but it doesn't works.

With `target: ""` it normally parse log records to `request.foo` and `response.foo`

Whats could be wrong?

---

<div class="post-metadata">

**Author:** ![Tetiana\_Kravchenko](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tetiana_kravchenko/32/102683_2.png) [@Tetiana\_Kravchenko](https://discuss.elastic.co/u/Tetiana_Kravchenko)\
**Post date:** [January 27, 2023, 8:56am UTC](https://discuss.elastic.co/t/target-field-in-ndjson/324014/2 "2023-01-27T08:56:57Z")

</div>

Hi @ddoroshenko

did you try to add `add_error_key: true` [configuration](https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-input-filestream.html#_ndjson) and check if you can see any errors?  
do you actually have `root` field? what will happen if you change the target field to not yet existing one?

---

<div class="post-metadata">

**Author:** ![ddoroshenko](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@ddoroshenko](https://discuss.elastic.co/u/ddoroshenko)\
**Post date:** [January 27, 2023, 9:19am UTC](https://discuss.elastic.co/t/target-field-in-ndjson/324014/3 "2023-01-27T09:19:13Z")

</div>

> did you try to add `add_error_key: true` [configuration](https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-input-filestream.html#_ndjson) and check if you can see any errors?

no, I'll try it

> do you actually have `root` field?

no, I have not.

---

<div class="post-metadata">

**Author:** ![ddoroshenko](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@ddoroshenko](https://discuss.elastic.co/u/ddoroshenko)\
**Post date:** [January 27, 2023, 12:25pm UTC](https://discuss.elastic.co/t/target-field-in-ndjson/324014/4 "2023-01-27T12:25:49Z")

</div>

I'm very sorry  
It was simpy inattention. I had `target` at the wrong level

---

<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 24, 2023, 2:26pm UTC](https://discuss.elastic.co/t/target-field-in-ndjson/324014/5 "2023-02-24T14:26:02Z")

</div>

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