Open ArktinenSieni opened 2 years ago
Also confused here, not sure if we just pass true
in or an app instance..
Looks like an app instance. My solution that worked:
export function metrics(): express.Express {
const metricsAppInstance = express();
// do stuff if you like
return metricsAppInstance
}
// The Express app is exported so that it can be used by serverless Functions.
export function app(metricsAppInstance: express.Express): express.Express {
const server = express();
...
// Prometheus Setup
server.use(
'*',
promBundle({
buckets: [0.10, 5, 15, 50, 100, 200, 300, 400, 500],
includeMethod: true,
includePath: true,
customLabels: {
app: 'angular-express-ssr'
},
autoregister: false,
metricsPath: '/metrics',
metricsApp: metricsAppInstance,
promClient: {
collectDefaultMetrics: {}
},
})
);
...
return server;
}
function run(): void {
const port = config.get('server.port') || 4000;
const metricsPort = config.get('metrics.port') || 4001;
const metricsServer = metrics();
// Start up the Node server
const server = app(metricsServer);
metricsServer.listen(metricsPort, ()=>{
console.log(`Node Express Prometheus Exporter listening on http://localhost:${metricsPort}`);
})
server.listen(port, () => {
console.log(`Node Express server listening on http://localhost:${port}`);
});
}
Hey! In #101 there were additional options added, but they're missing examples. I am unsure how I should use combination of
autoregister
andmetricsApp
. I could use the suggestions in #25 , but I'd rather use the options presented in the #101 PR.