# Filebeat: Variables in Output Hosts Doesn't Work

**URL:** https://discuss.elastic.co/t/filebeat-variables-in-output-hosts-doesnt-work/106226
**Category:** Beats
**Tags:** filebeat
**Created:** [November 2, 2017, 5:03pm UTC](https://discuss.elastic.co/t/filebeat-variables-in-output-hosts-doesnt-work/106226 "2017-11-02T17:03:28Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![derekcal](https://avatars.discourse-cdn.com/v4/letter/d/df788c/32.png) [@derekcal](https://discuss.elastic.co/u/derekcal)
#### Post date: [November 2, 2017, 5:03pm UTC](https://discuss.elastic.co/t/filebeat-variables-in-output-hosts-doesnt-work/106226/1 "2017-11-02T17:03:29Z")

</div>

Is there a way to include variables in output hosts? For example

> filebeat.yml

```
filebeat:
  config_dir: "/var/filebeat/conf.d"

output.kafka:
  hosts: "%{[fields.mybrokers]}"
  topic: "%{[fields.mytopic]}"

```

> conf.d/myconfig.yml

```
filebeat.prospectors:
- input_type: log

  paths:
    - /var/log/*

  fields:
    service: some_service
    mytopic: mytopic1
    mybrokers: ["host1", "host2"]

```

Doing this yields this erros: WARN kafka message: client/metadata got error from broker while fetching metadata:%!(EXTRA \*net.OpError=dial tcp: missing port in address %{[fields.mybrokers]})

Thanks!`Preformatted text`

---

<div class="post-metadata">

### Author: ![andrewkroh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrewkroh/32/3784_2.png) [@andrewkroh](https://discuss.elastic.co/u/andrewkroh)
#### Post date: [November 2, 2017, 8:53pm UTC](https://discuss.elastic.co/t/filebeat-variables-in-output-hosts-doesnt-work/106226/2 "2017-11-02T20:53:38Z")

</div>

You cannot control hosts or files (in the case of the file output) via variables. Doing so would require Beats to manage state and connections to each different host. You can only use variables to control the destination topic, but not the broker.

---

<div class="post-metadata">

### Author: ![derekcal](https://avatars.discourse-cdn.com/v4/letter/d/df788c/32.png) [@derekcal](https://discuss.elastic.co/u/derekcal)
#### Post date: [November 2, 2017, 9:16pm UTC](https://discuss.elastic.co/t/filebeat-variables-in-output-hosts-doesnt-work/106226/3 "2017-11-02T21:16:40Z")

</div>

Thanks for the reply!

---

<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: [November 30, 2017, 9:16pm UTC](https://discuss.elastic.co/t/filebeat-variables-in-output-hosts-doesnt-work/106226/4 "2017-11-30T21:16:48Z")

</div>

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