If you’ve ever built a Laravel application, you know the joy of opening Telescope and instantly seeing every request, query, exception, and job flowing through your system. Then you switch to NestJS and… it’s back to console.log debugging.

Not anymore.

NestLens gives NestJS developers the same level of visibility Laravel developers have enjoyed for years — without setup, without noise.

NestLens is a debugging and monitoring toolkit that brings Laravel Telescope’s developer experience to NestJS. One import, zero configuration for most setups, and you get a real-time dashboard tracking 19 different types of application events — including full GraphQL support with N+1 query detection.

Animated demo of the NestLens dashboard recording requests, queries and exceptions

Debug NestJS Like Never Before Laravel Telescope-inspired debugging and monitoring for NestJS.

Track requests, queries, exceptions, jobs, and 15 more watchers

with a beautiful real-time dashboard.

The Problem

NestJS is a phenomenal framework. TypeScript-first, decorator-based, batteries-included. But when it comes to observing what’s happening inside your application during development, the story is fragmented:

  • Logging requires manual setup and digging through terminal output
  • Database queries are invisible unless verbose ORM logging is enabled
  • Background jobs can fail silently, leaving you guessing
  • Cache operations happen in a black box
  • HTTP client calls to external APIs go completely untracked
  • GraphQL operations lack visibility into resolver performance and N+1 issues

Laravel solved this with Telescope years ago. The PHP ecosystem has it. Ruby has various debugging gems. But NestJS developers have been left cobbling together disparate solutions.

NestLens changes that.

What NestLens Is

NestLens is a NestJS module that captures, stores, and displays application events through a beautiful React dashboard. NestLens is designed primarily as a development and debugging tool, but it can run safely in production environments when using Redis storage.

NestLens dashboard in light mode

NestLens dashboard in dark mode

NestLens provides 19 specialized watchers, grouped into categories:

HTTP & Runtime

  • Request — Full HTTP request/response cycle with timing, memory usage, and user context
  • Exception — Errors with stack traces, grouped by similarity
  • Log — Application logs with level filtering
  • Dump — Debug dumps with multiple format support

Data & Infrastructure

  • Query — Database queries (TypeORM, Prisma, Raw SQL) with slow query detection
  • Model — ORM model operations tracking
  • Cache — Cache hits, misses, and operations
  • Redis — Redis command monitoring

API & GraphQL

  • GraphQL — Full GraphQL support for Apollo and Mercurius with N+1 query detection, subscription tracking, and field-level tracing

Async & Background

  • Job — Bull/BullMQ queue job tracking
  • Schedule — Cron job and scheduled task monitoring
  • Event — EventEmitter2 event tracking
  • Command — CLI command execution
  • Batch — Batch operation tracking

Communication

  • Mail — Email sending with HTML preview
  • Notification — Multi-channel notification tracking
  • HTTP Client — Outbound HTTP request monitoring
  • View — Template rendering tracking
  • Gate — Authorization gate results

Each watcher is purpose-built. The Query watcher understands TypeORM, Prisma, and raw SQL. The Job watcher hooks into Bull/BullMQ queues. The Request watcher captures controller actions, user sessions, and memory usage. The GraphQL watcher detects N+1 query patterns and tracks subscription lifecycles.

The dashboard, built with React and TailwindCSS, provides real-time filtering, search, and drill-down into every captured event.

How It Works (Architecture)

NestLens follows an event-driven collection pipeline:

Watcher → CollectorService → Buffer → Storage Driver → API → Dashboard 

Think of NestLens as a passive observer: it never changes your control flow, it only listens, correlates, and records.

This design keeps overhead low while still capturing high-fidelity debugging data.

Watchers as Interceptors

The Request watcher, for example, is a global NestJS interceptor. It wraps every incoming HTTP request, generates a correlation UUID, measures timing/memory, and collects the full request/response cycle:

@Injectable() export class RequestWatcher implements NestInterceptor { intercept(context: ExecutionContext, next: CallHandler) { const requestId = uuidv4(); const startTime = Date.now(); return next.handle().pipe( tap(responseBody => { this.collector.collect('request', { method, url, statusCode, duration, controllerAction, user, session, // ...30+ fields }, requestId); }) ); } } 

Type-Safe Collection

NestLens uses TypeScript discriminated unions to ensure compile-time safety. The Entry type is a union of 19 specific entry types, each with its own payload structure:

type Entry = RequestEntry | QueryEntry | ExceptionEntry | GraphQLEntry | ...; 
interface QueryEntry extends BaseEntry { type: 'query'; payload: { query: string; parameters?: unknown[]; duration: number; slow: boolean; source?: 'typeorm' | 'prisma' | 'raw'; }; } 
interface GraphQLEntry extends BaseEntry { type: 'graphql'; payload: { operationName?: string; operationType: 'query' | 'mutation' | 'subscription'; query: string; duration: number; hasErrors: boolean; potentialN1?: PotentialN1Warning[]; // ...and more }; } 

The CollectorService.collect() method uses generics to correlate the type string with the expected payload:

async collect<T extends EntryType>( type: T, payload: Extract<Entry, { type: T }>['payload'], requestId?: string ) 

This means calling collector.collect('query', { wrong: 'payload' }) is a compile-time error.

Buffered Writes

To avoid database I/O on every event, the collector buffers entries in memory. It flushes when either:

  • The buffer reaches 100 entries, or
  • One second has elapsed

Critical entries like exceptions bypass the buffer and save immediately.

Pluggable Storage Architecture

NestLens uses a pluggable storage architecture that adapts to the environment it runs in.

Instead of forcing a single storage backend, NestLens supports multiple storage drivers, each optimized for a specific use case:

  • Memory storage (default): zero-dependency, ideal for Docker, CI, and test environments
  • SQLite storage: optimized for local development and debugging sessions
  • Redis storage: designed for production and distributed environments

Storage drivers are loaded lazily. Native dependencies are only required if the selected driver needs them.

This design eliminates Docker container crashes caused by native SQLite bindings while keeping startup lightweight.

Key Features

Request Correlation

Every incoming HTTP request gets a UUID. All events triggered during that request — queries, logs, cache operations, exceptions — are tagged with the same ID. In the dashboard, clicking a request shows all related events in a single view.

Request detail page listing the queries, logs and cache operations recorded during that request

Query Monitoring with Slow Query Detection

The Query watcher captures every database operation with execution time. Queries exceeding your configured threshold are automatically flagged as slow.

Query list with execution times, slow queries highlighted

GraphQL Support with N+1 Detection

The new GraphQL watcher provides deep visibility into your GraphQL API:

  • Apollo and Mercurius support — Auto-detects your GraphQL server
  • N+1 query detection — Identifies resolver patterns that cause performance issues
  • Subscription tracking — Monitor WebSocket subscription lifecycles
  • Field-level tracing — Optional detailed resolver timing
  • Batch operation tracking — See batched queries together

GraphQL operation detail with resolver timing and N+1 warnings

Family Hashing

Similar exceptions are grouped by a “family hash” computed from the exception class and normalized message. Instead of seeing 50 identical TypeError entries, you see one group with a count.

Exceptions grouped by family hash, with occurrence counts

Tagging System

Entries can be tagged automatically (based on type, status, slow queries) or manually. The dashboard supports tag-based filtering with both AND and OR logic.

Entries filtered by tag in the dashboard

Security Built-In

NestLens is disabled in production by default. It only activates in development, local, and test environments. Additional security layers include:

  • IP Whitelist: Restrict access to specific addresses with wildcard support (192.168.1.*)
  • Role-Based Access: Return an AuthUser from your auth function to enable RBAC
  • Rate Limiting: Built-in protection against dashboard abuse (100 req/min default)
  • Sensitive Data Masking: Authorization headers, API keys, and passwords are automatically masked

Quick Start

Install the package:

npm install nestlens 

Import the module:

import { NestLensModule } from 'nestlens'; 
// Basic setup @Module({ imports: [ NestLensModule.forRoot({ enabled: process.env.NODE_ENV !== 'production', storage: { driver: 'memory' }, // default }), ], }) export class AppModule {} 

NestLens supports multiple storage drivers. Choose one depending on your environment:

// Memory (default – Docker / CI friendly) storage: { driver: 'memory' } 
// SQLite (local development) storage: { driver: 'sqlite', sqlite: { filename: '.cache/nestlens.db' } } 
// Redis (production / distributed) storage: { driver: 'redis', redis: { url: process.env.REDIS_URL } } 

Start your app and visit:

http://localhost:3000/nestlens 

NestLens dashboard overview at /nestlens

That’s it. No configuration files, no external services, no environment variables. NestLens auto-detects TypeORM, Prisma, Bull, and Apollo/Mercurius if they’re present.

API Tour

Module Configuration

NestLensModule.forRoot({ enabled: true, path: '/nestlens', // Dashboard path authorization: { allowedEnvironments: ['development', 'staging'], allowedIps: ['127.0.0.1', '10.0.*'], canAccess: (req) => req.user?.isAdmin, requiredRoles: ['developer'], }, storage: { driver: 'sqlite', sqlite: { filename: '.cache/my-app.db' }, }, pruning: { enabled: true, maxAge: 24, // hours interval: 60, // minutes }, watchers: { request: { ignorePaths: ['/health'], captureBody: true }, query: { slowThreshold: 100 }, // ms graphql: { detectN1Queries: true, n1Threshold: 10, traceFieldResolvers: false, }, job: true, cache: true, // ... 19 watchers available }, }) 

GraphQL Watcher Configuration

interface GraphQLWatcherConfig { enabled?: boolean; server?: 'apollo' | 'mercurius' | 'auto'; captureVariables?: boolean; captureResponse?: boolean; ignoreIntrospection?: boolean; ignoreOperations?: string[]; detectN1Queries?: boolean; n1Threshold?: number; traceFieldResolvers?: boolean; subscriptions?: { enabled?: boolean; trackMessages?: boolean; trackConnectionEvents?: boolean; }; } 

Core Services

For advanced use cases, NestLens exports its core services:

import { CollectorService, NestLensLogger } from 'nestlens'; 
// Manually collect custom events collector.collect('query', { query: 'SELECT...', duration: 5, slow: false }); 
// Replace NestJS default logger app.useLogger(app.get(NestLensLogger)); 
// Pause/resume recording collector.pause('Maintenance mode'); collector.resume(); 

Design Decisions and Tradeoffs

Storage Backends and Tradeoffs

NestLens supports multiple storage backends, each with clear tradeoffs.

NestLens can run safely in production environments when using Redis storage, but it is not a replacement for full observability platforms.

  • Memory storage is the default option, offering zero dependencies and maximum stability in Docker and CI environments.
  • SQLite storage provides a simple, file-based solution ideal for local development and inspection.
  • Redis storage enables safe usage in production and distributed setups where multiple instances are involved.

This flexibility allows NestLens to remain lightweight in development while scaling safely when needed.

Buffered Writes vs. Real-Time

The 100-entry / 1-second buffer introduces slight latency. An event might not appear in the dashboard for up to a second. This tradeoff favors throughput over immediacy — important when your app generates hundreds of events per second.

Exceptions bypass this buffer because developers need to see errors immediately.

Discriminated Unions vs. Flexibility

TypeScript discriminated unions provide compile-time safety but add complexity. Every new watcher requires updating the Entry union type. This was a deliberate choice: NestLens is a developer tool, and developer tools should catch mistakes early.

Performance Notes

  • Buffer size: 100 entries or 1 second, whichever comes first
  • Pagination: Cursor-based (not offset) for efficient large-dataset queries
  • Pruning: Automatic cleanup of entries older than 24 hours (configurable)
  • Memory: Rate limit entries are cleaned every 5 minutes
  • Indexing: SQLite indexes on type, request_id, created_at, and family_hash

For typical development usage (dozens of requests per minute), NestLens adds negligible overhead. The dashboard itself is rate-limited to prevent runaway polling.

Testing

NestLens includes comprehensive tests:

  • Unit tests (Jest): Collector service, pruning logic, family hashing, tag service
  • Integration tests: Module registration, watcher configurations, API guards
  • E2E tests (Playwright): Dashboard interactions, filtering, pagination

The test suite covers edge cases like corrupted JSON payloads, concurrent writes, and rate limit exhaustion.

When You Should (and Shouldn’t) Use It

Use NestLens When:

  • Developing locally and want visibility into your app
  • Debugging slow queries or cache misses
  • Tracing request flows through async operations
  • Debugging GraphQL N+1 query issues
  • Onboarding new team members who need to understand data flow
  • Running integration tests and want to inspect captured events

Don’t Use NestLens When:

  • Building an APM solution (use Datadog, New Relic, or OpenTelemetry)
  • Needing distributed tracing across microservices
  • Requiring long-term storage (default retention is 24 hours)

NestLens is a development tool, not a production monitoring solution. It trades durability and scalability for simplicity and speed.

What’s New in v0.3.0

  • GraphQL Watcher: Full support for Apollo and Mercurius with N+1 detection, subscription tracking, and field-level tracing
  • Dashboard Improvements: Better filtering, clickable badges for quick filtering, improved dark mode
  • API Refactoring: Clean DTO-based API with proper validation
  • 19 Watchers: Now covering every aspect of your NestJS application

Closing

NestLens fills a genuine gap in the NestJS ecosystem. If you’ve ever wished for Laravel Telescope while writing TypeScript, this is it.

The project is MIT-licensed, actively maintained, and open to contributions. Whether you’re debugging a stubborn query, tracing a job failure, hunting down GraphQL N+1 issues, or just curious what your app is doing under the hood, NestLens gives you visibility without the setup. If Telescope ever spoiled you, NestLens will feel instantly familiar. With its pluggable storage architecture, NestLens adapts to development, CI, Docker, and production environments without changing its core philosophy.

What's new since this was first written

NestLens is now at 0.19. The parts that changed the most:

  • NestJS 9 to 12, Node.js 22, 24 and 26. Every combination runs in CI on both the Express and Fastify adapters, and every release is installed from npm and booted before it counts.
  • Coding agents can read it. npx -y nestlens-mcp --url http://localhost:3000/nestlens starts an MCP server over a running NestLens (it is listed in the official MCP Registry as io.github.mogretici/nestlens), so Claude Code, Cursor or VS Code can look at the same requests, queries and exceptions you see in the dashboard. It is read-only unless you pass --allow-write.
  • GraphQL without wiring. Apollo and Mercurius are detected on their own; no plugin to register.
  • Safer to leave on. Data masking, IP allow-lists and role-based access are built in, and an unreachable Redis or an unwritable SQLite file falls back to memory instead of stopping your app.

Links