# MQTT Input Hostname

**URL:** <https://community.influxdata.com/t/mqtt-input-hostname/14180>\
**Category:** Telegraf\
**Created:** [May 5, 2020, 3:26am UTC](https://community.influxdata.com/t/mqtt-input-hostname/14180 "2020-05-05T03:26:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SeattleStephens](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/seattlestephens/32/9223_2.png) [@SeattleStephens](https://community.influxdata.com/u/SeattleStephens)\
**Post date:** [May 5, 2020, 3:26am UTC](https://community.influxdata.com/t/mqtt-input-hostname/14180/1 "2020-05-05T03:26:40Z")

</div>

The `host` value set for `mqtt_consumer` events appears to be random. Is there a way I can set the hostname in telegraph based upon a topic component.

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [May 6, 2020, 10:52pm UTC](https://community.influxdata.com/t/mqtt-input-hostname/14180/2 "2020-05-06T22:52:45Z")

</div>

Hello @SeattleStephens,  
Welcome! Can you please share your config?

---

<div class="post-metadata">

**Author:** ![SeattleStephens](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/seattlestephens/32/9223_2.png) [@SeattleStephens](https://community.influxdata.com/u/SeattleStephens)\
**Post date:** [May 14, 2020, 12:28am UTC](https://community.influxdata.com/t/mqtt-input-hostname/14180/3 "2020-05-14T00:28:38Z")

</div>

I should have set not random, it will use the `[agent]/hostname` value but I want to specify the hostname value from the mqtt topic.

```auto
[[inputs.mqtt_consumer]]
   topics = [
      "tele/+/+/+/SENSOR"
   ]

   username = "myuser"
   password = "mypass"

   data_format = "json"

```

I want the hostname to be a value associated with the device that sent the mqtt message. So, for the above mqtt topic, it would be nice to use a regular expression to specify one of the components as the hostname.

```auto
   topics = [
      "tele/(+:hostname)/+/+/SENSOR"
   ]

```
