CPU & Memory
Monitor system-level CPU and memory metrics from your servers.
Overview#
JustAnalytics collects infrastructure metrics from your servers automatically when using the Node.js SDK. Metrics include CPU usage, memory usage, event loop lag, and process-level statistics.
Automatic Collection#
When you initialize the SDK, infrastructure metrics are collected automatically every 30 seconds:
import JA from '@justanalyticsapp/node';
JA.init({
siteId: 'YOUR_SITE_ID',
apiKey: 'YOUR_API_KEY',
serviceName: 'api-server',
// Metrics collection is enabled by default
});
Collected Metrics#
CPU Metrics#
| Metric | Description | Unit |
|--------|-------------|------|
| system.cpu.usage | Overall CPU utilization | Percentage (0-100) |
| process.cpu.usage | Process CPU utilization | Percentage |
Memory Metrics#
| Metric | Description | Unit |
|--------|-------------|------|
| system.memory.usage | System memory usage | Percentage |
| system.memory.total | Total system memory | Bytes |
| system.memory.used | Used system memory | Bytes |
| process.memory.rss | Process RSS memory | Bytes |
| process.memory.heap_used | V8 heap used | Bytes |
| process.memory.heap_total | V8 heap total | Bytes |
| process.memory.external | V8 external memory | Bytes |
Node.js Metrics#
| Metric | Description | Unit |
|--------|-------------|------|
| nodejs.event_loop.lag | Event loop lag | Milliseconds |
| nodejs.active_handles | Active libuv handles | Count |
| nodejs.active_requests | Active libuv requests | Count |
Dashboard#
View infrastructure metrics at Monitoring > Infrastructure. The dashboard shows:
- Time-series charts for CPU and memory over selected time range
- Per-service breakdown to compare resource usage across services
- Threshold lines showing alert boundaries
- Anomaly detection highlighting unusual resource consumption
Alerts#
Set alerts on infrastructure metrics:
Rule: High CPU Usage
Metric: system.cpu.usage
Condition: > 80%
Window: 5 minutes
Severity: Warning
Rule: Memory Leak Detection
Metric: process.memory.heap_used
Condition: Increasing trend over 1 hour
Severity: Warning
Disabling Metric Collection#
If you don't need infrastructure metrics, disable them:
JA.init({
siteId: 'YOUR_SITE_ID',
apiKey: 'YOUR_API_KEY',
serviceName: 'api-server',
metrics: { enabled: false },
});