4

I was wondering if there was a way to centralize pm2 logs by either sending them to elastic search or integrating pm2 with the ELK stack in some way.

jman93
  • 367
  • 3
  • 9

1 Answers1

7

I would suggest you to use a pm2 module which would send logs to logstash using PM2's pm2.launchBus(errback) api (http://pm2.keymetrics.io/docs/usage/pm2-api/).

As you can see here https://github.com/cliv/pm2-gelf/blob/master/app.js#L24 It's pretty straight forward. The module listens pm2's log events and sends logs using gelf protocol in this case.

gkc
  • 449
  • 6
  • 18
  • I actually solved this by having logstash listen to the file in which my logs were going to. Thanks for the answer though! – jman93 Jul 15 '18 at 13:17