System Metrics Integration
System Metrics Integration
Laravel Health uses cboxdk/system-metrics to collect CPU, memory, disk, network, and uptime metrics across Linux, macOS, and containerized environments.
How It Works
The SystemMetricsService calls SystemMetrics::overview() to collect a snapshot of system state. This data powers:
- Prometheus metrics at
/health/metrics - JSON metrics at
/health/metrics/json - HTML dashboard at
/health/ui - System health checks (CPU, Memory, Disk Space)
Container Awareness
When running inside Docker or Kubernetes, system-metrics automatically detects cgroup limits (v1 and v2) and reports:
- Memory: container limit and usage instead of host memory
- CPU: quota and throttle information
- OOM kills: out-of-memory kill count
The memory.source field in JSON metrics indicates the source: host, cgroup_v1, or cgroup_v2.
Toggling Metric Groups
Enable or disable individual metric groups in config/health.php:
'metrics' => [
'system' => [
'cpu' => true,
'memory' => true,
'load' => true,
'storage' => true,
'network' => true,
],
],
Disabled groups are omitted from both Prometheus and JSON output.