Metrics, Monitoring & Logging (New Relic & Sentry)
Overview
Learnille utilizes New Relic as its primary Observability, Application Performance Monitoring (APM), and Log Management platform, combined with Sentry for real-time exception tracking.
📊 1. Observability Stack Architecture
[ Learnille Services ]
|
+---------------------------------+---------------------------------+
| | |
v v v
[ NestJS Backend API ] [ Vite React Frontends ] [ Background Workers / DB ]
- New Relic Node.js Agent - Sentry Browser SDK - New Relic Infrastructure
- Winston New Relic Transport - Web Vitals Tracking - Redis & Postgres Metrics
| | |
+---------------------------------+---------------------------------+
|
v
+---------------------------------------+
| New Relic One Hub |
| - APM & Transaction Tracing |
| - Centralized Log Analytics |
| - Real-time Alerting & Dashboards |
+---------------------------------------+
🛠 2. New Relic Integration Setup
Node.js Backend APM Configuration
In the NestJS server (server/src/main.ts and newrelic.js):
// newrelic.js
exports.config = {
app_name: ['Learnille API (Self-Hosted)'],
license_key: process.env.NEW_RELIC_LICENSE_KEY,
logging: {
level: 'info'
},
allow_all_headers: true,
attributes: {
exclude: [
'request.headers.cookie',
'request.headers.authorization'
]
}
};
Structured Log Transport
Winston logger routes all server logs directly to New Relic using the official @newrelic/winston-enricher transport.
🚨 3. Alerting Thresholds & Dashboards
| Metric | Target SLA | New Relic Alert Condition |
|---|---|---|
| API Error Rate | < 0.5% | Alert triggered if HTTP 5xx rate > 1% for 5 mins. |
| P95 Transaction Duration | < 250ms | Alert triggered if average response time > 500ms for 5 mins. |
| Database Query Latency | < 20ms | Alert triggered if SQL query duration > 100ms. |
| Host CPU / Memory Utilization | < 75% | Alert triggered if host RAM usage > 85%. |