-
Notifications
You must be signed in to change notification settings - Fork 3
Description
π οΈ Task: \Setup Logging & Monitoring Services In NESTJS
π Overview
To ensure observability, maintainability, and easier debugging across the NestJS backend, we need to implement comprehensive logging and monitoring services. This includes capturing logs for different levels of the application (info, warning, error, debug), tracking key application metrics, and optionally integrating external tools for real-time monitoring and alerting.
Setting up structured logging and monitoring will help developers detect issues early, trace requests effectively, and gain insights into system health and performance.
π― Goals
-
Logging
-
Integrate a logging service such as Winston, Pino, or extend NestJS's built-in
Logger. -
Support for log levels:
info,warn,error,debug. -
Include context such as timestamps, class/method names, request IDs (where applicable).
-
Log formatting: JSON or human-readable based on environment (
developmentvsproduction). -
Capture logs from:
- Application lifecycle events (startup, shutdown)
- HTTP requests/responses
- Errors/exceptions (should integrate with Global Exception Filter)
- Custom business events
-
-
Monitoring
-
Integrate lightweight metrics collection (e.g., using Prometheus, OpenTelemetry, or a SaaS tool like Datadog, Sentry, New Relic).
-
Track metrics such as:
- Request count and duration
- Error rates
- Uptime and memory usage
- CPU load (optional)
-
(Optional) Set up health checks using NestJS's
@nestjs/terminus
-
π§© Deliverables
- A
LoggerServiceor reusable wrapper for logging across the app - Environment-based logging configuration
- Metrics/monitoring module setup
- Documentation on how to use the logger and interpret the metrics
- Example usage in one or more modules (controllers/services)
β Acceptance Criteria
- Logs are consistent and include meaningful context
- Logging can be toggled or filtered via environment config
- Monitoring service is integrated and exposes metrics endpoint (e.g.,
/metricsfor Prometheus) - Logging works in harmony with Global Exception Filter
- No sensitive data is accidentally logged
- All tools and configurations are documented for team use