Monitoring and Observability
You cannot operate a notification system by checking whether the worker process is alive. The worker can be alive while the queue grows, provider calls fail, or users never receive security alerts.
The same principle applies to synchronous APIs. The Node.js API performance guide connects p50, p95, and p99 latency with PostgreSQL pool waits, Redis hit rates, event-loop delay, and capacity limits.
Core Metrics
Queue age is often more important than queue length. A queue of 10,000 marketing jobs may be fine. A queue where OTP jobs are 5 minutes old is not.
Dashboard Layout
Prometheus Metrics
notification_jobs_processed_total{channel="email",status="success"}
notification_jobs_failed_total{channel="sms",provider="twilio"}
notification_delivery_latency_seconds_bucket{channel="push"}
notification_queue_depth{queue="security-critical"}
notification_dlq_total{queue="transactional"}
Labels are powerful but can explode cardinality. Do not label metrics by user ID or notification ID.
Structured Logs
{
"level": "info",
"message": "email provider accepted",
"notificationId": "noti_123",
"eventId": "evt_456",
"channel": "email",
"provider": "sendgrid",
"providerMessageId": "msg_789",
"traceId": "trace_abc"
}
Logs should let support or engineering follow one notification across services.
Tracing
OpenTelemetry can carry trace context through events and jobs if you include trace IDs in metadata.
Alerting
Alert on user impact, not just noise.
Good alerts:
Noisy alerts:
The best alert tells you what users are experiencing and which system owner should respond.
Common Mistakes
- Monitoring only worker uptime.
- Alerting on every individual job failure.
- Not separating provider failures from validation failures.
- Using high-cardinality metric labels.
- Having no dashboard for queue age.
Interview Questions
- Which metric best shows notification delay?
- Why is queue age important?
- How would you trace one notification from event to provider?
- What alerts would you set for OTP delivery?
Exercise
Design a Grafana dashboard for a notification system. Include at least eight panels and two alerts.
What you will learn
Which metrics matter for notification systems.
How dashboards reveal queue and provider health.
How logs and traces help debug delivery problems.
How alerting should map to user impact.
Production checklist
- Queue length is monitored
- Delivery latency is measured
- Provider failures are separated
- Retry count is tracked
- DLQ has alerts
- Trace IDs connect event to provider call