Full NestJS Starter Kit — Part 4 Observability

Andrew Larsen
14 min readJan 17, 2024

In this series of articles we’re walking through how to create a NestJS starter kit to use for your cloud applications. In our previous article we walked through how to setup our application to use environment variables.

In this article we’ll walk through how to configure observability for our application via logging, tracing, and metrics.

If you are interested in learning more about what we do at Compoze Labs, please reach out!



Observability is a critical part of production applications. Our #1 goal is to identify issues as soon as they happen. If we’re learning about issues with our software directly from our customers, we know we need to beef up our observability.

We break down observability into the following areas:

  1. Logging
  2. Tracing
  3. Metrics & Monitoring
  4. Profiling
  5. Alerting
  6. Dashboards

A number of the above areas are covered by our APM (application performance monitoring) tools. For our starter kit, we’ll focus on logging, tracing, and metrics


For our logging setup, we want to ensure we have the following features and functionality available for our developers

  1. Logging levels (debug, info, warn, error)
  2. Ability to configure logging levels at runtime
  3. Format optimized for searching (generally JSON)

Based on these requirements, we find winston to be the best logging library available for Node based ecosystems. There are two ways to leverage winston with NestJS. Either statically (most common way we’ve seen done) or as a first class provider. Normally we’d view using IoC to inject loggers as unnecessary. However, in order to to handle log tracing we’ll need to set it up as a provider.

Configuring Winston

In order to configure winston, we first need to install the dependency

$ pnpm i winston