This document explains the Prometheus + Grafana-based monitoring added to the Flight platform, covering two services and three critical APIs.
Responsible for:
- Flight search
- Filtering (price, date, trips)
- Read-heavy API traffic
Responsible for:
- Booking creation
- Payment initiation
- Booking expiry (cron-based cleanup)
Each service exposes its own Prometheus /metrics endpoint and has a dedicated Grafana dashboard.
- prom-client – metric collection
- Prometheus – scraping & storage
- Grafana – visualization
- Express middleware – request-level metrics
| Metric | Type | Purpose |
|---|---|---|
http_requests_total_* |
Counter | Total requests by method, route, status |
http_request_duration_seconds_* |
Histogram | API latency distribution |
active_requests_* |
Gauge | In-flight requests |
process_cpu_seconds_total |
Counter | CPU usage |
process_resident_memory_bytes |
Gauge | Memory usage |
event_loop_lag_seconds |
Gauge | Node.js event loop health |
Tracks how users search for flights.
Labels:
has_pricehas_datehas_trips
This allows answering questions like:
- Are users filtering by price or date?
- Which combinations are most common?
- Are we optimizing the right search paths?
Tracks number of results returned per search, useful for:
- Detecting empty searches
- Oversized responses
- Query optimization
Key Panels:
- Flight search filter usage (stacked view)
- Request latency buckets
- Active search requests
- CPU & memory usage
- Event loop lag
- Process restarts
This dashboard helps identify:
- Slow search queries
- Load spikes
- Memory leaks
- Inefficient filters
Total booking attempts initiated.
Successful booking creations.
Failures categorized by explicit reason:
AUTH_FAILEDNO_SEATSINVALID_FLIGHT
Tracks bookings that expired before payment (cron-based).
This metric directly reflects:
- User drop-offs
- Payment friction
- UX issues
Attempt → Success
→ Failed (reason)
→ Expired (no payment)
This is a true business funnel, not just request counts.
Key Panels:
- Booking attempts vs success (pie)
- Expired vs paid bookings (time series)
- Booking request rates
- Request latency
- CPU & memory usage
- Active requests & handlers
This dashboard answers:
- Are users completing bookings?
- Where are they dropping?
- Are failures increasing?
- Is infra impacting booking success?
- Rising
booking_failed_total{reason}→ business logic or auth issues - Increasing latency buckets → performance regressions
- Growing expired bookings → payment UX problems
- Track peak active requests
- CPU/memory trends over time
- Identify most-used search filters
- Optimize common search paths
- Metrics are namespaced per service to avoid collisions.
- Units follow Prometheus conventions (
seconds, counters only increase). - Middleware ensures consistent coverage across APIs.
- Business metrics are emitted only where domain events occur, not blindly at middleware level.