# Regarding reading value of field variable in filebeat

**URL:** https://discuss.elastic.co/t/regarding-reading-value-of-field-variable-in-filebeat/38511
**Category:** Beats
**Tags:** filebeat
**Created:** [January 6, 2016, 1:54pm UTC](https://discuss.elastic.co/t/regarding-reading-value-of-field-variable-in-filebeat/38511 "2016-01-06T13:54:50Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![vivc](https://avatars.discourse-cdn.com/v4/letter/v/ce7236/32.png) [@vivc](https://discuss.elastic.co/u/vivc)
#### Post date: [January 6, 2016, 1:54pm UTC](https://discuss.elastic.co/t/regarding-reading-value-of-field-variable-in-filebeat/38511/1 "2016-01-06T13:54:50Z")

</div>

I want to read a variable from a config file and assign it to filed variablet. Please suggest how can we do this.

---

<div class="post-metadata">

### Author: ![vivc](https://avatars.discourse-cdn.com/v4/letter/v/ce7236/32.png) [@vivc](https://discuss.elastic.co/u/vivc)
#### Post date: [January 7, 2016, 4:12am UTC](https://discuss.elastic.co/t/regarding-reading-value-of-field-variable-in-filebeat/38511/2 "2016-01-07T04:12:05Z")

</div>

Sorry i think there was a typo. To make it clear how can i read the value of a variable in config file and assign it to filebeat filed and then output to logstash.

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [January 7, 2016, 6:49am UTC](https://discuss.elastic.co/t/regarding-reading-value-of-field-variable-in-filebeat/38511/3 "2016-01-07T06:49:29Z")

</div>

And by variable you mean environment variable? I'm pretty sure that's not possible out of the box. What are you trying to accomplish, i.e. what problem is solved by being able to read an environment variable?

---

<div class="post-metadata">

### Author: ![vivc](https://avatars.discourse-cdn.com/v4/letter/v/ce7236/32.png) [@vivc](https://discuss.elastic.co/u/vivc)
#### Post date: [January 8, 2016, 7:02am UTC](https://discuss.elastic.co/t/regarding-reading-value-of-field-variable-in-filebeat/38511/4 "2016-01-08T07:02:31Z")

</div>

I'm trying to get the server name from where the logs are forwarded to ELK . Instead of hard coding the name of each server as a field in the filebeat.yml file i'm trying to read it from some config file and pass it on to logstash. Please suggest if there is any alternative for this if it cannot be read from enviornment variable.

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [January 8, 2016, 8:11am UTC](https://discuss.elastic.co/t/regarding-reading-value-of-field-variable-in-filebeat/38511/5 "2016-01-08T08:11:22Z")

</div>

Filebeat already adds the hostname for you, see [https://www.elastic.co/guide/en/beats/filebeat/current/exported-fields.html](https://www.elastic.co/guide/en/beats/filebeat/current/exported-fields.html).

---

<div class="post-metadata">

### Author: ![vivc](https://avatars.discourse-cdn.com/v4/letter/v/ce7236/32.png) [@vivc](https://discuss.elastic.co/u/vivc)
#### Post date: [January 11, 2016, 6:33am UTC](https://discuss.elastic.co/t/regarding-reading-value-of-field-variable-in-filebeat/38511/6 "2016-01-11T06:33:44Z")

</div>

Thanks for the information. Currently i've copied filebeat in to a chassis and forwarding the same. Let me check if i the chassis name will send to logstash using filebeat.

---

<div class="post-metadata">

### Author: ![Sai\_Theodore](https://avatars.discourse-cdn.com/v4/letter/s/e79b87/32.png) [@Sai\_Theodore](https://discuss.elastic.co/u/Sai_Theodore)
#### Post date: [December 20, 2016, 9:46am UTC](https://discuss.elastic.co/t/regarding-reading-value-of-field-variable-in-filebeat/38511/7 "2016-12-20T09:46:00Z")

</div>

Though Filebeat send the hostname under the beat properties, I would like to send the hostname in a custom field. Is there a way to do this? This is required because the output is sent to kafka and the consumer expects the message in a specific format.

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [December 20, 2016, 10:03am UTC](https://discuss.elastic.co/t/regarding-reading-value-of-field-variable-in-filebeat/38511/8 "2016-12-20T10:03:39Z")

</div>

@Sai_Theodore, please start a new thread for your unrelated question.

---

<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: [July 5, 2017, 9:50pm UTC](https://discuss.elastic.co/t/regarding-reading-value-of-field-variable-in-filebeat/38511/9 "2017-07-05T21:50:09Z")

</div>


