@redhare/prometheus-nest
v0.0.2
Published
nodejs monitor module for prometheus
Downloads
2
Keywords
Readme
Prometheus for Nest
Introduction
@infra-node-kit/prometheus-nest
is a node prometheus client for Nest
framework. It it based on @infra-node-kit/prometheus-common
.
Initial the metrics
// definition
// this method will call the prom-client collectDefaultMetrics and register the customMetrics
function initMetrics(options?: DefaultMetricsCollectorConfiguration): void;
import { initMetrics } from '@infra-node-kit/prometheus-nest'
initMetrics()
Use the module
import { PrometheusModule } from '@infra-node-kit/prometheus-nest'
@Module({
imports: [PrometheusModule.forRoot()]
})e
export class AppModule{}
- custom the metrics path
import { PrometheusModule } from '@infra-node-kit/prometheus-nest'
@Module({
imports: [PrometheusModule.forRoot({
metricsPath: '/custom_metrics_path'
})]
})
Use the middleware
middleware helps you collect the request metrics apiConcurrency
and requestHistogram
import {PrometheusMiddleware} from '@infra-node-kit/prometheus-nest'
app.use(PrometheusMiddleware)
If you want customize the metrics label, you can create middleware by yourself and call the collectRequestMetrics
.
More customization
can refer to @infra-node-kit/prometheus-common
. this package include all the functions of it.