# Setting host.hostname mapping to static

**URL:** https://discuss.elastic.co/t/setting-host-hostname-mapping-to-static/213224
**Category:** Beats
**Tags:** metricbeat
**Created:** [December 27, 2019, 7:04pm UTC](https://discuss.elastic.co/t/setting-host-hostname-mapping-to-static/213224 "2019-12-27T19:04:30Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Ryan\_Downey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ryan_downey/32/35987_2.png) [@Ryan\_Downey](https://discuss.elastic.co/u/Ryan_Downey)
#### Post date: [December 27, 2019, 7:04pm UTC](https://discuss.elastic.co/t/setting-host-hostname-mapping-to-static/213224/1 "2019-12-27T19:04:31Z")

</div>

ECE 2.3  
Metricbeat 7.0.0 & 7.5.0

I need some guidance on how to stop the dynamic templating for host.hostname of our metricbeats. We've got a third party product that can only read data from the host.hostname field if the mapping is the same as metricbeat 7.0.0. From the dev tools I got part of the host.hostname mapping and as you can see its just has a "type" of "keyword".

```auto
        "host" : {
          "properties" : {
            "architecture" : {
              "type" : "keyword",
              "ignore_above" : 1024
            },
            "containerized" : {
              "type" : "boolean"
            },
            "geo" : {
              "properties" : {
                "city_name" : {
                  "type" : "keyword",
                  "ignore_above" : 1024
                },
                "continent_name" : {
                  "type" : "keyword",
                  "ignore_above" : 1024
                },
                "country_iso_code" : {
                  "type" : "keyword",
                  "ignore_above" : 1024
                },
                "country_name" : {
                  "type" : "keyword",
                  "ignore_above" : 1024
                },
                "location" : {
                  "type" : "geo_point"
                },
                "name" : {
                  "type" : "keyword",
                  "ignore_above" : 1024
                },
                "region_iso_code" : {
                  "type" : "keyword",
                  "ignore_above" : 1024
                },
                "region_name" : {
                  "type" : "keyword",
                  "ignore_above" : 1024
                }
              }
            },
            "group" : {
              "type" : "keyword"
            },
            "hostname" : {
              "type" : "keyword",
              "ignore_above" : 1024
            },

```

I've tried to load the 7.0.0 template manually and apply it to metricbeat-7.5.0 so that the application can read the data. What I'm having problems with is that the host.hostname field is being mapped as a text field and keyword field it appears which is preventing the app from reading the data correctly. How do I set the mapping up so that hostname is just type keyword and not text.

```auto
      "host": {
        "properties": {
          "architecture": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "containerized": {
            "type": "boolean"
          },
          "group": {
            "type": "keyword"
          },
          "hostname": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },

```

---

<div class="post-metadata">

### Author: ![Ryan\_Downey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ryan_downey/32/35987_2.png) [@Ryan\_Downey](https://discuss.elastic.co/u/Ryan_Downey)
#### Post date: [December 30, 2019, 1:40pm UTC](https://discuss.elastic.co/t/setting-host-hostname-mapping-to-static/213224/2 "2019-12-30T13:40:12Z")

</div>

To update this a little bit both of the templates have the hostname section setup as

```auto
},
          "hostname": {
            "ignore_above": 1024,
            "type": "keyword"
          },

```

The problem seems to be when metricbeat 7.5.0 starts sending data to the index it automatically changes it to

```auto
 "hostname": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },

```

Which is why the program can't read it.

---

<div class="post-metadata">

### Author: ![Ryan\_Downey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ryan_downey/32/35987_2.png) [@Ryan\_Downey](https://discuss.elastic.co/u/Ryan_Downey)
#### Post date: [December 31, 2019, 6:01pm UTC](https://discuss.elastic.co/t/setting-host-hostname-mapping-to-static/213224/3 "2019-12-31T18:01:01Z")

</div>

Seems like something is adding the fields portion to every field but I'm not sure where its coming from.

```auto
{
 "mapping": {
  "properties": {
   "@timestamp": {
    "type": "date"
   },
   "@version": {
    "type": "text",
    "fields": {
     "keyword": {
      "type": "keyword",
      "ignore_above": 256
     }
    }
   },
   "agent": {
    "properties": {
     "ephemeral_id": {
      "type": "text",
      "fields": {
       "keyword": {
        "type": "keyword",
        "ignore_above": 256
       }
      }
     },
     "hostname": {
      "type": "text",
      "fields": {
       "keyword": {
        "type": "keyword",
        "ignore_above": 256
       }
      }
     }....

```

---

<div class="post-metadata">

### Author: ![Ryan\_Downey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ryan_downey/32/35987_2.png) [@Ryan\_Downey](https://discuss.elastic.co/u/Ryan_Downey)
#### Post date: [January 2, 2020, 1:47pm UTC](https://discuss.elastic.co/t/setting-host-hostname-mapping-to-static/213224/4 "2020-01-02T13:47:44Z")

</div>

The problem seems to be using an alias for metricbeat. If I don't create an alias for metricbeat-7.5.0 the mapping is correct. If I apply an alias to an index I the mapping adds the extra field.

What I've done is stop all reporting 7.5 metricbeats and delete the metricbeat-7.5.0-2020.01.03 index. From there I ran the command below to setup an index with date math that has the alias metricbeat-7.5.0.

```auto
PUT /%3Cmetricbeat-7.5.0-%7Bnow%2Fd%7D-000001%3E
{
 "aliases": {
  "metricbeat-7.5.0": {
   "is_write_index": true
 }
 }
}

```

When this setup occurs the mapping changes which is causing the issue for our 3rd party program.

---

<div class="post-metadata">

### Author: ![Ryan\_Downey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ryan_downey/32/35987_2.png) [@Ryan\_Downey](https://discuss.elastic.co/u/Ryan_Downey)
#### Post date: [January 3, 2020, 6:52pm UTC](https://discuss.elastic.co/t/setting-host-hostname-mapping-to-static/213224/5 "2020-01-03T18:52:35Z")

</div>

I'm running into a second issue with this. What seems to be happening and what I can't figure out is why a template for metricbeat-7.3.0 keeps coming up when the only beats reporting to this cluster are either 7.0 or 7.5.

---

<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 1, 2020, 8:43am UTC](https://discuss.elastic.co/t/setting-host-hostname-mapping-to-static/213224/7 "2020-02-01T08:43:52Z")

</div>

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