Unable to visualize span.http.response.status_code

I'm unable to use the span.http.response.status_code field (or any of the span.http fields) on APM span documents when building a custom visualization.

I can see the info I want in Discover, but it says that it is type Unknown field and that there is "no cached mapping for this field". I've attempted "Refresh field list" several times on the apm-* index pattern. I've also attempted creating a new apm*span* index pattern, but it has the same issue.

Is span.http.response.status_code unavailable for Kibana visualizations, or is there something going wrong when I'm refreshing the field list? Thanks in advance

For anyone else that has this issue, this field span.http fields are not indexed by default.

I first had to overwrite the template with a new one containing the span.http.response.status_code field by adding this to my apm-server.yml:

setup.template.overwrite: true
setup.template.append_fields:
- name: span.http.response.status_code
  type: long

and restarted the APM-Server.

This fixed the issue for new data. In order to search on old data, I needed to reindex using the Reindex API:

curl -XPOST "http://<elasticsearch>:9200/_reindex" -H 'Content-Type: application/json' -d'{"source":{"index":"apm-7.8.1-span-2020.08.26"},"dest":{"index":"apm-7.8.1-span-2020.08.26-reindexed"}}'

and deleting the apm-7.8.1-span-2020.08.26 index once I was done