Skip to content

Add metrics module #967

Open
Open
@weeco

Description

@weeco

For a better monitoring of my Nest microservices I'd like to have a metrics endpoint which can be scraped by monitoring systems like Prometheus.

I believe a module written for NestJS could provide quite a couple metrics by default:

  • Metrics about the Node process resources (offered by default in the prom-client library)
  • Requests per second
    • All endpoints alltogether
    • Each endpoint
  • Request duration
    • All endpoints alltogether
    • Each endpoint
  • Number of responses grouped by response status codes for
    • All endpoints alltogether
    • Each endpoint
  • Response times in a bucket ([0-20ms, 20-50ms, ...]) for
    • All endpoints alltogether
    • Each endpoint

Beside these default metrics which could be offered out of the box, it should be easily possible to inject the metrics module into services, so that users can create custom metrics for their business code (e. g. number of registrations).

Using these metrics we can easily attach grafana to it and monitor our services:

Grafana dashboard

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions