prometheus-metrics-middleware
Prometheus metrics middleware for NodeJS apps on top of prom-client.
Install
npm i prometheus-metrics-middleware --save
yarn add prometheus-metrics-middleware
Usage
import express from 'express'
import metricsMiddleware from 'prometheus-metrics-middleware'
const app = express()
app.use(
metricsMiddleware({
metricsPath: '/metrics',
metricsPrefix: 'my_sample_app_',
timeout: 1000 * 60,
})
)
app.get('/healthcheck', (req: Request, res: Response) => {
...
})
app.listen(3000)
Options
Name | Default | Description |
---|---|---|
metricsPath |
/metrics | Route to fetch metrics from prometheus |
metricsPrefix |
- | Prefix for metric names |
timeout |
- | Timeout (ms) for how often the probe should be fired |
Access metrics
Prometheus format
curl http[s]://[host]:[port]/metrics
JSON format
curl http[s]://[host]:[port]/metrics.json