# Added label to APM which has the incorrect index 'type'

**URL:** <https://discuss.elastic.co/t/added-label-to-apm-which-has-the-incorrect-index-type/215650>\
**Category:** APM\
**Tags:** nodejs\
**Created:** [January 19, 2020, 10:17pm UTC](https://discuss.elastic.co/t/added-label-to-apm-which-has-the-incorrect-index-type/215650 "2020-01-19T22:17:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthew\_Petrie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matthew_petrie/32/59145_2.png) [@Matthew\_Petrie](https://discuss.elastic.co/u/Matthew_Petrie)\
**Post date:** [January 19, 2020, 10:17pm UTC](https://discuss.elastic.co/t/added-label-to-apm-which-has-the-incorrect-index-type/215650/1 "2020-01-19T22:17:55Z")

</div>

**Kibana version** : 7.5.1  
**Elasticsearch version** : 7.5.1  
**APM Server version** : 7.5.1  
**APM Agent language and version** : Node.JS 3.3.0  
**Original install method (e.g. download page, yum, deb, from source, etc.) and version**: Elastic Cloud

**Description of the problem including expected versus actual behavior. Please include screenshots (if relevant)**:  
I have added 2 labels which are integers to a span using `.addLabels({ "bucket": 213 })` however the index seems to have set them to the type `keyword`. I am wanting to use the labels in visualizations however if I use the Area visualization and choose `average` for the Y-axis the labels do not appear in the `fields` dropdown (the labels exist in the documents when I view them in discover). I'm not sure if this is related to the fields having the wrong type in the index or not - if this is the issue how can I correct this?

Any help would be greatly appreciated!

Thanks, Matthew

---

<div class="post-metadata">

**Author:** ![axw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/axw/32/28197_2.png) [@axw](https://discuss.elastic.co/u/axw)\
**Post date:** [January 21, 2020, 5:34am UTC](https://discuss.elastic.co/t/added-label-to-apm-which-has-the-incorrect-index-type/215650/2 "2020-01-21T05:34:23Z")

</div>

@Matthew_Petrie, the Node.js agent currently does not support sending numeric label values; instead, they are stringified. I've opened [https://github.com/elastic/apm-agent-nodejs/issues/1598](https://github.com/elastic/apm-agent-nodejs/issues/1598) to track adding support.

In the mean time, you could [add a filter](https://www.elastic.co/guide/en/apm/agent/nodejs/current/agent-api.html#apm-add-filter) to the agent to parse the strings back to numbers before sending to the server.

---

<div class="post-metadata">

**Author:** ![Matthew\_Petrie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matthew_petrie/32/59145_2.png) [@Matthew\_Petrie](https://discuss.elastic.co/u/Matthew_Petrie)\
**Post date:** [January 21, 2020, 1:56pm UTC](https://discuss.elastic.co/t/added-label-to-apm-which-has-the-incorrect-index-type/215650/3 "2020-01-21T13:56:48Z")

</div>

Thanks @axw - hadn't realised the APM filter function ran after the stringification.

As per the GitHub issue, if I put the filter in it will cause issues with the index - any advice on how to resolve this? (I'm pretty new to Elastic)

Thanks for your reply 🙂

---

<div class="post-metadata">

**Author:** ![axw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/axw/32/28197_2.png) [@axw](https://discuss.elastic.co/u/axw)\
**Post date:** [January 22, 2020, 1:55am UTC](https://discuss.elastic.co/t/added-label-to-apm-which-has-the-incorrect-index-type/215650/4 "2020-01-22T01:55:54Z")

</div>

[Mapping | Elasticsearch Guide [8.11] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html#update-mapping) says:

> Except for supported [mapping parameters](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-params.html), you can’t change the mapping or field type of an existing field. Changing an existing field could invalidate data that’s already indexed.
> 
> If you need to change the mapping of a field, create a new index with the correct mapping and [reindex](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html) your data into that index.

You have a few options:

- Delete your existing docs and mappings. I assume you want to keep data, I'm just listing this for completeness.
- Start using a different name for your labels, so there's no collision with the existing mapping/field type.
- Create a new mapping, and reindex your data. You could either drop the existing stringified label fields, or convert to numbers, using an Ingest node pipeline.

---

<div class="post-metadata">

**Author:** ![Matthew\_Petrie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matthew_petrie/32/59145_2.png) [@Matthew\_Petrie](https://discuss.elastic.co/u/Matthew_Petrie)\
**Post date:** [January 22, 2020, 9:15am UTC](https://discuss.elastic.co/t/added-label-to-apm-which-has-the-incorrect-index-type/215650/5 "2020-01-22T09:15:38Z")

</div>

> [@axw](#):
>
> Create a new mapping, and reindex your data. You could either drop the existing stringified label fields, or convert to numbers, using an Ingest node pipeline.

This sounds great - hadn't realised you could drop certain fields.

Thanks for your time, it's greatly appreciated! 👍

---

<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 12, 2020, 5:15am UTC](https://discuss.elastic.co/t/added-label-to-apm-which-has-the-incorrect-index-type/215650/6 "2020-02-12T05:15:40Z")

</div>

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