@redhare/prometheus-nest
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

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.

Readme

Keywords

none

Package Sidebar

Install

npm i @redhare/prometheus-nest

Weekly Downloads

2

Version

0.0.2

License

ISC

Unpacked Size

13.5 kB

Total Files

11

Last publish

Collaborators

  • tobywan
  • yann001
  • jiushu
  • keyunlei
  • zsynuting