How hourly metrics work
masterBy default, metrics are recorded at a daily level. To track metrics with hour-level granularity, use the hourly() method.
Important: Hourly metrics are stored separately from daily metrics even if they share the same name. Using hourly metrics increases database row count by approximately 24x. Use them only when hour-level granularity or timezone-specific querying is required.
// Record an hourly metric
metric('api:requests')->hourly()->record();
// Querying hourly metrics
use DirectoryTree\\Metrics\\Metric;
// Get metrics for this hour
$metrics = Metric::thisHour()->get();
// Get metrics for last hour
$metrics = Metric::lastHour()->get();
// Get metrics for a specific date and hour
$metrics = Metric::onDateTime(Carbon::parse('2025-10-19 14:00:00'))->get();