# The "fields" property only works with the dictionary type

**URL:** <https://discuss.elastic.co/t/the-fields-property-only-works-with-the-dictionary-type/147578>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [September 6, 2018, 1:16pm UTC](https://discuss.elastic.co/t/the-fields-property-only-works-with-the-dictionary-type/147578 "2018-09-06T13:16:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![devantoine](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/devantoine/32/35268_2.png) [@devantoine](https://discuss.elastic.co/u/devantoine)\
**Post date:** [September 6, 2018, 1:16pm UTC](https://discuss.elastic.co/t/the-fields-property-only-works-with-the-dictionary-type/147578/1 "2018-09-06T13:16:03Z")

</div>

Hi,

The "fields" property is here to add custom fields to an input.

The doc says:

> Fields can be scalar values, arrays, dictionaries, or any nested combination of these.

> **[Log input | Filebeat Reference \[8.11\] | Elastic](https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-input-log.html#filebeat-input-log-fields)**

But if you set a scalar value like this:

```
fields: "foobar"

```

Filebeat outputs the following error:

> Exiting: Error in initing input: required 'object', but found 'string' in field 'filebeat.inputs.0.fields' (source:'/etc/filebeat/filebeat.yml')

If I set the field using the array, like this:

```
fields: ["foobar"]

```

or this:

```
fields:
  - "foobar"

```

I've got no error but the field is not in the ouput.

The only way it works is with the dictionary type:

```
fields:
    foobar: true

```

Am I missing something or the doc is wrong?

---

<div class="post-metadata">

**Author:** ![adrisr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/adrisr/32/25423_2.png) [@adrisr](https://discuss.elastic.co/u/adrisr)\
**Post date:** [September 6, 2018, 2:01pm UTC](https://discuss.elastic.co/t/the-fields-property-only-works-with-the-dictionary-type/147578/2 "2018-09-06T14:01:26Z")

</div>

The wording used in the docs is a bit misleading. When it says "Fields can be ..." it really means "Fields values can be ...".

So basically it means that for every field you declare, you can assign it a "scalar value, array, dictionary, or any nested combination of these."

```
fields:
  field_scalar1: "string"
  field_scalar2: 42     
  field_array: ["hello", "world"]
  field_dict:
      key1: value1
      key2: value2

```

The contents of the `fields:` key itself are always a dictionary

---

<div class="post-metadata">

**Author:** ![devantoine](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/devantoine/32/35268_2.png) [@devantoine](https://discuss.elastic.co/u/devantoine)\
**Post date:** [September 6, 2018, 2:49pm UTC](https://discuss.elastic.co/t/the-fields-property-only-works-with-the-dictionary-type/147578/3 "2018-09-06T14:49:12Z")

</div>

Oh, I see.

Thanks for the quick reply!

---

<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 4, 2018, 2:49pm UTC](https://discuss.elastic.co/t/the-fields-property-only-works-with-the-dictionary-type/147578/4 "2018-10-04T14:49:13Z")

</div>

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