wavded / graygelf

A complete GELF client, server, and proxy for Graylog
MIT License
56 stars 17 forks source link

Pass remote.address and remote.port to emitted message #17

Open megastef opened 7 years ago

megastef commented 7 years ago

On the server side it would be interesting to know from where the packets arrive. The UDP socket provides this details, but the message processing ignores this info.

wavded commented 7 years ago

GELF requires host to be set in the message, but I suppose that could be set improperly by the client, and likely wouldn't include the port. You can sniff those details by adding your own event handler currently, e.g.

var gelfserver = require('graygelf/server')
var server = gelfserver()
server.on('message', function (gelf) {
  // handle parsed gelf json here
  console.log('received message', gelf.short_message)
})
server.listen(12201)
server._udp.on('message', function (buf, rinfo) {
  // view raw packet info here
  console.log(rinfo)
}