# Field references sometimes resolved and sometimes not

**URL:** <https://discuss.elastic.co/t/field-references-sometimes-resolved-and-sometimes-not/170511>\
**Category:** Logstash\
**Created:** [March 1, 2019, 2:22pm UTC](https://discuss.elastic.co/t/field-references-sometimes-resolved-and-sometimes-not/170511 "2019-03-01T14:22:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cawoodm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cawoodm/32/14083_2.png) [@cawoodm](https://discuss.elastic.co/u/cawoodm)\
**Post date:** [March 1, 2019, 2:22pm UTC](https://discuss.elastic.co/t/field-references-sometimes-resolved-and-sometimes-not/170511/1 "2019-03-01T14:22:52Z")

</div>

Elasticsearch + LogStash 6.5 / FileBeat 6.6 / Windows Server

In FileBeat we define the fields "source", "server" and "system" and add them together in Logstash to a field `logfile` according to the template `%{[fields][source]}-%{[fields][server]}-%{[fields][system]}`.

```auto
mutate {
    add_field => {
        "server" => "%{[fields][server]}"
        "logfile" => "%{[fields][source]}-%{[fields][server]}-%{[fields][system]}"
    }
}

```

This used to work fine but lately we keep getting (sporadic) error messages and the field often/sometimes being set to a combination of the processed and unprocessed template.

> [2019-03-01T14:24:18,518][ERROR][logstash.outputs.elasticsearch] Could not index event to Elasticsearch. {:status=\>400, :action=\>["index", {:\_id=\>"access-app02-prod\_2019-03-01T13:24:07.000Z\_337202708,access-app02-prod,%{[fields][source]}-%{[fields][server]}-%{[fields][system]}_2019-03-01T13:24:07.000Z_%{offset}", :\_index=\>"access-prod,%{[fields][system]}", :\_type=\>"\_doc", :\_routing=\>nil}, #LogStash::Event:0x4d265dfc], :response=\>{"index"=\>{"\_index"=\>"access-prod,%{[fields][system]}", "\_type"=\>"\_doc", "\_id"=\>"access-app02-prod\_2019-03-01T13:24:07.000Z\_337202708,access-app02-prod,%{[fields][source]}-%{[fields][server]}-%{[fields][system]}_2019-03-01T13:24:07.000Z_%{offset}", "status"=\>400, "error"=\>{"type"=\>"invalid\_index\_name\_exception", "reason"=\>"Invalid index name [access-prod,%{[fields][system]}], must not contain the following characters [, ", \*, \, \<, |, ,, \>, /, ?]", "index\_uuid"=\>"_na_", "index"=\>"access-prod,%{[fields][system]}"}}}}

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/f/3/f38b0a0e22ea3343b0f9341b85afa6e0536dfb50.png)

I feel like there has been some change of late in how field templates `%{}`are handled. In particular we seem to have no issues with `%{field}` but more with `%[field][subfield]`.

---

<div class="post-metadata">

**Author:** ![cawoodm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cawoodm/32/14083_2.png) [@cawoodm](https://discuss.elastic.co/u/cawoodm)\
**Post date:** [March 6, 2019, 11:59am UTC](https://discuss.elastic.co/t/field-references-sometimes-resolved-and-sometimes-not/170511/2 "2019-03-06T11:59:38Z")

</div>

This issue only goes away if we stop setting `document_id` in the elasticsearch output. Something is seriously amiss with either ES or LS.

---

<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:** [April 3, 2019, 11:59am UTC](https://discuss.elastic.co/t/field-references-sometimes-resolved-and-sometimes-not/170511/3 "2019-04-03T11:59:43Z")

</div>

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