Skip to content

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:

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.