How To Monitor a Distributed System with a NestJS Application

Let us take a look into NestJS’ internal healthcheck module, and combine it with a Prometheus client

Itchimonji
CP Massive Programming

--

Nowadays, it is essential to monitor our application for availability (for example, in a Kubernetes cluster) and to ensure that all dependencies are achievable to provide the user with a good experience.

Additionally, it is important to check a service’s dependencies (e.g., a database or authorization system) and report their unhealthiness.

There are numerous applications and frameworks that make this possible. But in this article, I want to focus on NestJS, Terminus, and an embedded Prometheus client framework.

A Distributed System of Microservices

On many platforms, we can see how a system of dependent microservices is developed to satisfy the customer (e.g., Ebay TECH, Facebook). The biggest challenge is to ensure that all microservices can be reached by each other and thus to provide fail-safety to keep the customer happy. If a service is not available (e.g. network problems) or even fails, a responsible person has to get notified, and the service restarts itself if necessary.

--

--

Itchimonji
CP Massive Programming

Freelancer | Site Reliability Engineer (DevOps) / Kubernetes (CKAD) | Full Stack Software Engineer | https://patrick-eichler.com/links