pm2-prom-module-client
v1.0.3
Published
This client facilitates communication among all your concurrently running nodejs applications in PM2 with pm2-prom-module
Downloads
8,077
Maintainers
Readme
Client for PM2-Prom-Module
This client facilitates communication among all your concurrently running nodejs applications in PM2 with PM2-Prom-Module. It transmits all of prom-client metrics, enhancing the monitoring and performance analysis of your applications.
Install
npm install pm2-prom-module-client
How to use
To establish communication between pm2-prom-module
and your application, import the initMetrics
function and provide your Registry as an argument.
Have a look on example:
import client from 'prom-client';
import { initMetrics } from 'pm2-prom-module-client';
const registry = new client.Registry();
const PREFIX = `nodejs_app_`;
const metricRequestCounter = new client.Counter({
name: `${PREFIX}request_counter`,
help: 'Show total request count',
registers: [registry],
});
// Register your prom-client Registry
initMetrics(registry);
// ...
app.get('/*', async (req: AppFastifyRequest, res) => {
// ...
metricRequestCounter?.inc();
// ...
});
Do not forget to install
pm2-prom-module
to your PM2.