# Logstash server label shipped with logs

**URL:** <https://discuss.elastic.co/t/logstash-server-label-shipped-with-logs/319478>\
**Category:** Logstash\
**Created:** [November 21, 2022, 4:19pm UTC](https://discuss.elastic.co/t/logstash-server-label-shipped-with-logs/319478 "2022-11-21T16:19:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lubimamp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lubimamp/32/114060_2.png) [@lubimamp](https://discuss.elastic.co/u/lubimamp)\
**Post date:** [November 21, 2022, 4:19pm UTC](https://discuss.elastic.co/t/logstash-server-label-shipped-with-logs/319478/1 "2022-11-21T16:19:04Z")

</div>

Hi Everyone,

i have 2+ logstash servers in cluster and i would like to have some tag/flag/whatever which to tell me from which logstash server exactly the message was shipped. I have cases in which one of the logstash servers is not working properly and not sending any messages and i would like to have a tag/label/flag some custom message in the logs so I can understand from which server is coming.

thank you!

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [November 21, 2022, 6:49pm UTC](https://discuss.elastic.co/t/logstash-server-label-shipped-with-logs/319478/2 "2022-11-21T18:49:15Z")

</div>

If you have the hostname in an environment variable you could use

```
mutate { add_field => { "someField" => "${HOST}" } }

```

---

<div class="post-metadata">

**Author:** ![Rios](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rios/32/95745_2.png) [@Rios](https://discuss.elastic.co/u/Rios)\
**Post date:** [November 22, 2022, 2:46am UTC](https://discuss.elastic.co/t/logstash-server-label-shipped-with-logs/319478/3 "2022-11-22T02:46:37Z")

</div>

For env. variables:  
Linux: `mutate { add_field => { "ls-env" => "${HOSTNAME}" } }`  
Windows: `mutate { add_field => { "ls-env" => "${COMPUTERNAME}" } }`

If you have Logstash 8+, it's included in ECS v8, you should get it by default. Check in Ruby debug, you should see, something like this.

> {  
> "@timestamp" =\> 2022-11-22T02:16:34.832529600Z,  
> "host" =\> {  
> "name" =\> "somehost"  
> ...  
> }

`mutate { add_field => { "ls-host" => "%{[host][name]}" } }`

On older LS versions, you can get by ruby:

```auto
ruby { 
 code => "event.set('ls-host', Socket.gethostname)" 
}

```

---

<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:** [December 20, 2022, 2:47am UTC](https://discuss.elastic.co/t/logstash-server-label-shipped-with-logs/319478/4 "2022-12-20T02:47:31Z")

</div>

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