How to include a server identifier in nxlog output and reference it in logstash

logstashnxlog

If I have nxlog running on multiple IIS servers (say web1, web2, web3, web4). How can I add an identifier to the nxlog output which is being sent to logstash.

Then within logstash I want to create a custom index with the server identifier (ex %{server_id})

output { 
    elasticsearch_http { 
        host => "localhost" 
        port => 9200
        index => "%{server_id}-logstash-%{+YYYY.MM.dd}"
    }
}

Best Answer

In the Output element you are using to send to logstash, add:

   Exec $Hostname = '<ServerHostname>';
Related Topic