Alert::with('rule')->orderByDesc('created_at')->limit(50)->get(), 'alert_stats' => [ 'total_rules' => AlertRule::count(), 'resolved_24h' => Alert::where('status', 'resolved')->where('resolved_at', '>=', now()->subDay())->count(), ], 'dashboards' => [], ]); } public function metrics(string $target) { [$type, $id] = explode(':', $target, 2); $metrics = Metric::where('target_type', $type) ->where('target_id', $id) ->where('recorded_at', '>=', now()->subHour()) ->orderBy('recorded_at') ->get(); return response()->json($metrics); } public function alerts() { return Inertia::render('Monitoring/Alerts', [ 'rules' => AlertRule::orderByDesc('created_at')->paginate(20), ]); } public function acknowledge(Alert $alert) { $alert->update([ 'status' => 'acknowledged', 'acknowledged_by' => auth()->id(), 'acknowledged_at' => now(), ]); return back()->with('success', 'Alert acknowledged.'); } public function dashboards() { return Inertia::render('Monitoring/Dashboards'); } }