# MetricBeat - Unable to create dynamic namespace

**URL:** <https://discuss.elastic.co/t/metricbeat-unable-to-create-dynamic-namespace/147147>\
**Category:** Beats\
**Tags:** metricbeat\
**Created:** [September 4, 2018, 6:01am UTC](https://discuss.elastic.co/t/metricbeat-unable-to-create-dynamic-namespace/147147 "2018-09-04T06:01:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kathir\_J](https://avatars.discourse-cdn.com/v4/letter/k/e47774/32.png) [@Kathir\_J](https://discuss.elastic.co/u/Kathir_J)\
**Post date:** [September 4, 2018, 6:01am UTC](https://discuss.elastic.co/t/metricbeat-unable-to-create-dynamic-namespace/147147/1 "2018-09-04T06:01:00Z")

</div>

MetricBeat - Unable to create dynamic namespace.

My project requirement is to create a dynamic namespace(based on hostname).  
How do i get access to host name or beat name inside metricbeat.yml

I tried something similar to **namespace: "[host][name]"** but no luck. Could you guide me how to add dynamic namespace?

---

<div class="post-metadata">

**Author:** ![adrisr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/adrisr/32/25423_2.png) [@adrisr](https://discuss.elastic.co/u/adrisr)\
**Post date:** [September 4, 2018, 7:59am UTC](https://discuss.elastic.co/t/metricbeat-unable-to-create-dynamic-namespace/147147/2 "2018-09-04T07:59:47Z")

</div>

I'm not sure if this is going to work out, but you can try with:

```
namespace: "%{[beat.name]}"

```

or

```
namespace: "%{[beat.host]}"
```

---

<div class="post-metadata">

**Author:** ![Kathir\_J](https://avatars.discourse-cdn.com/v4/letter/k/e47774/32.png) [@Kathir\_J](https://discuss.elastic.co/u/Kathir_J)\
**Post date:** [September 4, 2018, 8:42am UTC](https://discuss.elastic.co/t/metricbeat-unable-to-create-dynamic-namespace/147147/3 "2018-09-04T08:42:54Z")

</div>

I tried these already but it doesn't pick the beat name.

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

${path.config} is working for namespace but its useless as it produces path.

I have gone through fields.yml file there are lot of fields like, beat.name, beat.version..... but accessing it under metricbeat.yml for namespace is still not known.  
(  
Am wondering how it can be accessed under elasticsearch output but why not in namespace?  
output.elasticsearch:

hosts: ["localhost:9200"]  
index: "**metricbeat-%{[beat.version]}-%{+yyyy.MM.dd}**"  
)  
Am confused. ☹  
Any idea?

---

<div class="post-metadata">

**Author:** ![exekias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/exekias/32/28718_2.png) [@exekias](https://discuss.elastic.co/u/exekias)\
**Post date:** [September 4, 2018, 1:02pm UTC](https://discuss.elastic.co/t/metricbeat-unable-to-create-dynamic-namespace/147147/4 "2018-09-04T13:02:25Z")

</div>

You have access to all environment variables, as per [https://www.elastic.co/guide/en/beats/metricbeat/current/using-environ-vars.html](https://www.elastic.co/guide/en/beats/metricbeat/current/using-environ-vars.html)

You should be able to do:

```auto
namespace: ${HOSTNAME}

```

Best regards

---

<div class="post-metadata">

**Author:** ![Kathir\_J](https://avatars.discourse-cdn.com/v4/letter/k/e47774/32.png) [@Kathir\_J](https://discuss.elastic.co/u/Kathir_J)\
**Post date:** [September 6, 2018, 12:15pm UTC](https://discuss.elastic.co/t/metricbeat-unable-to-create-dynamic-namespace/147147/5 "2018-09-06T12:15:54Z")

</div>

No.It doesn't help. It works under ElasticSearch index name but not under namespace.

---

<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:** [October 4, 2018, 12:15pm UTC](https://discuss.elastic.co/t/metricbeat-unable-to-create-dynamic-namespace/147147/6 "2018-10-04T12:15:56Z")

</div>

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