Skip to content

An extended dashboard for Laravel Horizon written using Livewire

License

Notifications You must be signed in to change notification settings

VincentBean/horizon-extended-dashboard

Repository files navigation

Laravel Horizon Extended Dashboard

Laravel Horizon Extended Dashboard

This is an alternative dashboard for Laravel Horizon written with Livewire. The reason that I've created this is that the default Horizon dashboard lacks features such as controls and a queue filter.

Features

  • Detailed overview of Horizon, all data that is available is shown
  • Pause and terminate controls from the dashboard for the master process and supervisors
  • Batch views
  • Job Views for recent, pending, completed and failed
    • Filtering on queue
  • Catch all exceptions that occur on your jobs
  • Detailed statistics
    • Job runtime
    • Queue runtime
    • Attempts
    • CPU/memory usage per queue
    • And more
  • Retry/requeue any job
  • List all retries of a job

Installation

Require this package via composer:

composer require vincentbean/horizon-extended-dashboard

Then publish the assets:

php artisan horizon-dashboard:publish

You can optionally add this to your post install or update composer script to make sure you always have the latest version published:

{
  "scripts": {
    "post-update-cmd": [
      "@php artisan horizon-dashboard:publish"
    ]
  }
}

Statistics

To collect queue statistics you can add these commands to your scheduler:

    protected function schedule(Schedule $schedule)
    {
        $schedule->command('horizon:snapshot')->everyFifteenMinutes();
        $schedule->command('horizon-dashboard:queue-snapshot')->everyFifteenMinutes();
    }

Aggregating Data

To prevent your database from growing, this package includes two aggregate and cleanup commands. You can adjust the values to work best for your install. The parameters for the aggregate commands are in minutes.

    protected function schedule(Schedule $schedule)
    {
        $schedule->command('horizon-dashboard:aggregate-queue-statistics --interval=60 --keep=240')->everyFifteenMinutes();
        $schedule->command('horizon-dashboard:aggregate-job-statistics --interval=15 --keep=60')->everyFifteenMinutes();
    }

For this you have to disable strict mode in your MySQL database config in config/database.php

Deleting old statistics

    protected function schedule(Schedule $schedule)
    {
        $schedule->command('horizon-dashboard:cleanup-statistics --hours=168')->daily();
        $schedule->command('horizon-dashboard:cleanup-exceptions --hours=168')->everyFifteenMinutes();
    }

Authentication

This package uses de same authentication middleware as Laravel Horizon.

Usage

You can access the dashboard by going to /horizon-dashboard

License

The MIT License (MIT). Please see License File for more information.