# Filebeat add\_fields processor

**URL:** <https://discuss.elastic.co/t/filebeat-add-fields-processor/290990>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [December 5, 2021, 7:42pm UTC](https://discuss.elastic.co/t/filebeat-add-fields-processor/290990 "2021-12-05T19:42:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![fgjensen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fgjensen/32/62320_2.png) [@fgjensen](https://discuss.elastic.co/u/fgjensen)\
**Post date:** [December 5, 2021, 7:42pm UTC](https://discuss.elastic.co/t/filebeat-add-fields-processor/290990/1 "2021-12-05T19:42:22Z")

</div>

Hello colleagues;

I am trying to add an ECS event.dataset with the add\_fields processor similar to several of the Filebeat modules e.g., the Apache module which add the event datasets apache.access and apache.error.

I use the add\_fields processor and configure it with either

```auto
target: ''

```

or

```auto
events_under_root: true

```

However what I get is the event.data set under the fields key:

```auto
fields:
  event.dataset: "app.access"

```

What I expect is the event.dataset at the root level of the document

```auto
event.dataset: "app.access"

```

e.g. as all the Filebeat modules do. What am I missing?

I know I can use the add\_tags processor but I am already using this for other purposes.

BR  
Flemming

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [December 5, 2021, 8:58pm UTC](https://discuss.elastic.co/t/filebeat-add-fields-processor/290990/2 "2021-12-05T20:58:03Z")

</div>

Hi @fgjensen

Did you try exactly like this? I just did and it worked as expected.

```auto
processors:
  - add_fields:
      target: ''
      fields:
        event.dataset: "app.access"

```

The `events_under_root` is not a valid setting in the `add_fields` processor.

There could be a subtle conflict ...are you using a module or just a generic input? If you are using a module like ngnix or something it could be overwriting ` event.dataset`... I would need to test that case.

---

<div class="post-metadata">

**Author:** ![fgjensen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fgjensen/32/62320_2.png) [@fgjensen](https://discuss.elastic.co/u/fgjensen)\
**Post date:** [December 6, 2021, 4:32pm UTC](https://discuss.elastic.co/t/filebeat-add-fields-processor/290990/3 "2021-12-06T16:32:05Z")

</div>

Hi @stephenb

Thanks for taking time to addressing this question.

I configured the processors exactly as you suggests. It did not work for me.

I should add that the inputs are filestreams, several filestream inputs are configured in one configuration file under the input.d directory and each input has more than one processor defined.

I can share the configuration file if it helps you.

BR  
Flemming

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [December 6, 2021, 6:30pm UTC](https://discuss.elastic.co/t/filebeat-add-fields-processor/290990/4 "2021-12-06T18:30:16Z")

</div>

sure if you like I suspect the processors are not in the right place, you should probably try putting them aligned with each input... see [here](https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-input-filestream.html#_processors_6)

Its hard to tell when I can only see snippets

---

<div class="post-metadata">

**Author:** ![fgjensen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fgjensen/32/62320_2.png) [@fgjensen](https://discuss.elastic.co/u/fgjensen)\
**Post date:** [December 8, 2021, 12:29pm UTC](https://discuss.elastic.co/t/filebeat-add-fields-processor/290990/5 "2021-12-08T12:29:04Z")

</div>

Hi @stephenb

I reviewed my implementation and must admit I had an error.

This works for the add\_fields processor and the dissect processor in a filestream input.

```auto
    processors:
      - add_fields:
          target: ''
          fields:
            event.dataset: "cas.log"
      - if:
          regexp:
            message: '\s\bWARN\s|\s\bERROR\s' # Fetch WARN or ERROR levels into the log.level field
        then:
          - dissect:
              tokenizer: "%{} %{log.level} %{}"
              field: "message"
              target_prefix: ''
              ignore_failure: true
              ignore_missing: true
              overwrite_keys: true

```

Thanks for your help.

Best regards  
Flemming

---

<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:** [January 5, 2022, 2:29pm UTC](https://discuss.elastic.co/t/filebeat-add-fields-processor/290990/6 "2022-01-05T14:29:57Z")

</div>

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