# Logstash - How to use the node.name as a field value?

**URL:** <https://discuss.elastic.co/t/logstash-how-to-use-the-node-name-as-a-field-value/70753>\
**Category:** Logstash\
**Created:** [January 6, 2017, 6:42am UTC](https://discuss.elastic.co/t/logstash-how-to-use-the-node-name-as-a-field-value/70753 "2017-01-06T06:42:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hk-awil](https://avatars.discourse-cdn.com/v4/letter/h/50afbb/32.png) [@hk-awil](https://discuss.elastic.co/u/hk-awil)\
**Post date:** [January 6, 2017, 6:42am UTC](https://discuss.elastic.co/t/logstash-how-to-use-the-node-name-as-a-field-value/70753/1 "2017-01-06T06:42:30Z")

</div>

Hello

I would like to add the `node.name` value to an extra message field.  
Is this value readable from inside of logstash?

I tried to use the `node.name` like the host field: `"fqdn" => "%{host}"` without success.  
Dose anybody know how to access the [node.name](http://node.name) value?

This is my example:

```
input {
    file {
      path => "/var/log/xyz/service.log"
      type => "xyz-daemon"
      add_field => { "service-port" => "12345"
                                  "service-name" => "my-service"
                                  "fqdn" => "%{host}"
                                  "node-name" => ????
    }
}

```

Best Regards,  
Daniel

---

<div class="post-metadata">

**Author:** ![eperry](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eperry/32/551_2.png) [@eperry](https://discuss.elastic.co/u/eperry)\
**Post date:** [January 7, 2017, 5:21pm UTC](https://discuss.elastic.co/t/logstash-how-to-use-the-node-name-as-a-field-value/70753/2 "2017-01-07T17:21:45Z")

</div>

in 2.4 and probly 5.1 logstash there is a logstash CLI argument "--allow-env" which lets you reference Environment varables like HOSTNAME 😃

[https://www.elastic.co/guide/en/logstash/current/environment-variables.html](https://www.elastic.co/guide/en/logstash/current/environment-variables.html)

I do this for my tracking "HEARTBEATS" so I know which logstash's are running and which one need to be restarted

```auto
add_field => { "service-port" => "12345"
                                  "service-name" => "my-service"
                                  "fqdn" => "%{host}"
                                  "node-name" => "${HOSTNAME}"
    }

```

---

<div class="post-metadata">

**Author:** ![hk-awil](https://avatars.discourse-cdn.com/v4/letter/h/50afbb/32.png) [@hk-awil](https://discuss.elastic.co/u/hk-awil)\
**Post date:** [January 9, 2017, 8:16am UTC](https://discuss.elastic.co/t/logstash-how-to-use-the-node-name-as-a-field-value/70753/3 "2017-01-09T08:16:46Z")

</div>

Hi ed

Thank you very much for your suggestion. Short after I have written my question,  
I dicided to use an environment variable to solve the problem 🙂

Regards,  
Daniel

---

<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 6, 2017, 8:17am UTC](https://discuss.elastic.co/t/logstash-how-to-use-the-node-name-as-a-field-value/70753/4 "2017-02-06T08:17:00Z")

</div>

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