Closed eben0 closed 2 years ago
I'm trying to run the bundle in a cluster but I get a time out error from prom-client. I'm using the same example from the readme.
const cluster = require('cluster'); const promBundle = require('express-prom-bundle'); const numCPUs = Math.max(2, require('os').cpus().length); const express = require('express'); if (cluster.isMaster) { for (let i = 1; i < numCPUs; i++) { cluster.fork(); } const metricsApp = express(); metricsApp.use('/metrics', promBundle.clusterMetrics()); metricsApp.listen(9999); console.log('cluster metrics listening on 9999'); console.log('call localhost:9999/metrics for aggregated metrics'); } else { const app = express(); app.use(promBundle({ autoregister: false, // disable /metrics for single workers includeMethod: true })); app.use((req, res) => res.send(`hello from pid ${process.pid}\n`)); app.listen(3000); console.log(`worker ${process.pid} listening on 3000`); }
GET http://localhost:9999/metrics
Error: Operation timed out. at Timeout._onTimeout (/Users/xxx/git/bim/node_modules/prom-client/lib/cluster.js:59:18) at listOnTimeout (internal/timers.js:551:17) at processTimers (internal/timers.js:494:7)
Node version: v14.8.0
Update:
initiating AggregatorRegistry seems to resolve this issue:
AggregatorRegistry
new promBundle.promClient.AggregatorRegistry();
closing, as the example has been updated, thanks to @diegoximenes
I'm trying to run the bundle in a cluster but I get a time out error from prom-client. I'm using the same example from the readme.
GET http://localhost:9999/metrics
Node version: v14.8.0