@viewsonic-mvb/nest-fastify-status-monitor
TypeScript icon, indicating that this package has built-in type declarations

0.0.8 • Public • Published

nest-fastify-status-monitor

NPM

nest-status-monitor on npm License

Simple, self-hosted module based on Socket.io and Chart.js to report realtime server metrics for Nest.js based node servers.

Status monitor page

Installation & setup default config

  1. Run npm install @viewsonic-mvb/nest-fastify-status-monitor --save
  2. Setup module:
import {
  WebStatusMonitorModule,
  WebStatusMonitorConfiguration,
} from '@viewsonic-mvb/nest-fastify-status-monitor';

@Module({
  imports: [WebStatusMonitorModule.setUp()],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}
  1. Run server and go to /status

Run examples

  1. Go to cd examples/test-fastify-status-monitor
  2. Run yarn i
  3. Run server yarn start
  4. Go to http://localhost:3001

Options

Monitor can be configured by passing options object during initialization of module.

Default config:

{
  pageTitle: 'Nest.js Monitoring Page',
  port: 3001,
  path: '/status',
  socketPath: '/socket.io',
  ignoreStartsWith: '/admin',
  healthChecks: [],
  spans: [
    {
      interval: 1, // Every second
      retention: 60, // Keep 60 datapoints in memory
    },
    {
      interval: 5, // Every 5 seconds
      retention: 60,
    },
    {
      interval: 15, // Every 15 seconds
      retention: 60,
    },
  ],
  chartVisibility: {
    cpu: true,
    mem: true,
    load: true,
    heap: true,
    eventLoop: true,
    responseTime: true,
    rps: true,
    statusCodes: true,
  },
}

Health Checks

You can add a series of health checks to the configuration that will appear below the other stats. The health check will be considered successful if the endpoint returns a 200 status code.

// config
healthChecks: [
  {
    protocol: 'http',
    host: 'localhost',
    path: '/health',
    port: 3000,
  }
];

License

Forked from nest-status-monitor

Package Sidebar

Install

npm i @viewsonic-mvb/nest-fastify-status-monitor

Weekly Downloads

133

Version

0.0.8

License

MIT

Unpacked Size

51.5 kB

Total Files

38

Last publish

Collaborators

  • sidraw
  • richy_yang
  • single9