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

(Daniel Ambauen) #1


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,

(Ed) #2

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:


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

(Daniel Ambauen) #3

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:


(system) #4

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