title: Export PM2 Cluster Stats to Prometheus
body: <p>I am trying to add monitoring to a Node.js PM2 cluster where I am looking for aggregated stats in prometheus which I will then import in Grafana.</p>
  
  <p>I have been able to configure prom-client and get metrics for a single process to prometheus and grafana but not a pm2 cluster.</p>
  
  <p>I referred <a href="https://github.com/siimon/prom-client/issues/165" rel="nofollow noreferrer">https://github.com/siimon/prom-client/issues/165</a> and <a href="https://github.com/siimon/prom-client/issues/80" rel="nofollow noreferrer">https://github.com/siimon/prom-client/issues/80</a> and both says its not possible.</p>
  
  <p>Is there any other way to do it? I also referred <a href="https://github.com/redar9/pm2-cluster-prometheus" rel="nofollow noreferrer">https://github.com/redar9/pm2-cluster-prometheus</a> but can't get it working as well.</p>
  
  <p>I referred <a href="https://github.com/Unitech/pm2/issues/2035" rel="nofollow noreferrer">https://github.com/Unitech/pm2/issues/2035</a> and I was able to use it in my script and find which is the master and which is the slave. But not sure how I go ahead from there.</p>
  
  <p>Any help is appreciated. </p>