Fielddata is disabled on text fields by default. Set fielddata=true

I am running elastic stack v 7.2.0 on kubernetes and I am getting this error in the elasticsearch while accessing the metricbeat dashboard

Caused by: java.lang.IllegalArgumentException: Fielddata is disabled on text fields by default. Set fielddata=true on [host.name] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead.

My questions is If I have manually added the template and dashboards, then why am I getting this error? With the template added should not the required mapping go inside the index? I saw some answers which suggested to apply the required mapping. But then In this case how should i give the index name on which this mapping is to be applied as my metricbeat index would be created daily with each new date. I want this explicit mapping to persist across all the metric beat indices formed with each date .
PUT /what-should-be-the-index-name/_mapping