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

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 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

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

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

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

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 :slight_smile:

Regards,
Daniel

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