NestJS Observability

Implement structured logging, request tracing, Prometheus metrics, and health checks in NestJS.

Updated Jan 22, 2026
One-click install
npx skills add https://github.com/ngxtm/skill-rule --skill nestjs-observability
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: NestJS Observability
Source: https://github.com/ngxtm/skill-rule/tree/main/rules/nestjs/observability
Command: npx skills add https://github.com/ngxtm/skill-rule --skill nestjs-observability

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the need for robust logging, tracing, and metrics in NestJS applications, ensuring better monitoring, debugging, and operational insight.

Core Features & Use Cases

  • Structured Logging: Implements high-performance JSON logging using nestjs-pino, with mandatory redaction of sensitive fields and context injection.
  • Request Tracing: Ensures all log lines include a reqId for correlation across microservices and downstream systems.
  • Metrics Exposure: Sets up Prometheus metrics endpoints using @willsoto/nestjs-prometheus for key application performance indicators.
  • Health Checks: Integrates Terminus for defining liveness and readiness probes, including database and memory checks.
  • Use Case: Debugging a complex transaction across multiple microservices by tracing a single reqId through all relevant logs, or monitoring application memory usage to prevent crashes.

Quick Start

Configure NestJS to use structured logging with Pino and Prometheus metrics.

Frequently Asked Questions about NestJS Observability

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement structured logging in NestJS?

Implement structured logging in NestJS by configuring the nestjs-pino module to output high-performance JSON logs. This setup injects request context and applies mandatory redaction to sensitive fields for secure observability.

How do I trace requests across NestJS microservices?

Trace requests across NestJS microservices by injecting a correlation ID into every log line as a reqId. This ID correlates logs across all downstream systems to debug complex transactions effectively.

How do I expose Prometheus metrics in a NestJS application?

Expose Prometheus metrics in a NestJS application by integrating the @willsoto/nestjs-prometheus module. This sets up dedicated endpoints to expose key application performance indicators for monitoring.

How do I set up health checks for NestJS using Terminus?

Set up health checks for NestJS using Terminus to define liveness and readiness probes. This integration monitors critical dependencies like database connectivity and memory usage to prevent crashes.

What is the best way to add observability to a NestJS app?

Add observability to a NestJS app by combining structured logging, request tracing, and Prometheus metrics. This approach provides comprehensive application insight by correlating requests and monitoring performance indicators.

Does this NestJS observability setup support log redaction?

Yes, this NestJS observability setup supports log redaction through the nestjs-pino module. It enforces mandatory redaction of sensitive fields within your structured JSON logs to ensure secure monitoring.