Search code examples
node.jsloggingwinstonloggly

How to send host and application information to Loggly through winston-loggly in Node.js


I'm using the winston-loggly module in a Node app in order to send logging information to Loggly. My logger is instantiated like so:

var logger = new(winston.Logger)({
  transports: [
    new (winston.transports.Console)({ level: 'debug' }),
    new (winston.transports.Loggly)({
      inputToken: {TOKEN},
      subdomain: {SUBDOMAIN},
      tags: ['Winston-NodeJS', 'logtag'],
      json:true,
      level: 'debug'
    })
  ]
}); 

On my Loggly account I can see the logs that have been sent. I want to create source groups so that I can filter out by host and tags, and so far I've gotten it to work when only tags are specified fro the source group. When I tried adding the IP specified in the "clientHost" of the log messages to the"host" field of the source group, that group stopped displaying any results.

I've looked through the documentation to see how to send the host and application information, but I couldn't find how to do so through winston-loggly.


Solution

  • Source groups only support syslog.host right now. http.clientHost isn't supported there yet. You might try using a tag instead.