keepsuit / laravel-spyglass
Lightweight production-safe monitoring dashboard for Laravel
Requires
- php: ^8.3
- illuminate/contracts: ^12.41 || ^13.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^10.5 || ^11.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- spatie/laravel-ray: ^1.35
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-28 15:59:02 UTC
README
Spyglass is a single, lightweight dashboard that gives an overview of a Laravel application in production: scheduled tasks, queues, exceptions and logs. It is meant to replace Telescope, Horizon's dashboard and Pulse with something that is safe to keep enabled in production.
Warning
Spyglass is under active development and is not ready for use yet.
Goals
- Low overhead: entries are buffered in memory and written in a single batch at the end of each request, job or command. Nothing is pushed to the queue, and storage failures never break the application.
- Driver agnostic: data is collected from Laravel events, so queue metrics are the same whether workers run with
queue:workor Horizon. No Redis requirement. - Multi-tenant aware: a configurable set of Context keys is stored with every entry, and a resolver turns them into a filterable scope (for example the current tenant).
- Everything optional: every module can be enabled or disabled from the config file.
Planned features
- Schedule: task list, last run, duration and outcome, next run, missed runs.
- Queues: processed, failed, released and timed out counters per queue and job class, pending/running/delayed sizes, failed jobs with retry and delete.
- Exceptions: grouped by fingerprint, with occurrences, first and last seen, resolve and reopen on regression.
- Logs: a
spyglasslog channel that storeswarningand above. - Health: database and cache connectivity, pending jobs per queue, debug mode in production, PHP, Laravel and package versions, deployed version (
APP_VERSION).
Later: scheduler and queue heartbeats, alerts, on-demand request tracing, and an API for custom modules.
Stored data
Spyglass never stores job payloads, query bindings or the driver message of query errors, and masks query string values unless allowed by the query_allowlist option of the exceptions module. It does store exception messages, the authenticated user id of an occurrence, log messages with their context and the configured Context keys: these can hold personal data, so treat the Spyglass tables like application logs when it comes to retention and access.
Known limitations
- On Laravel 12, a background run skipped for overlap mid-execution shows as interrupted.
- On Laravel 12, a sub-minute task skipped for overlap right after a failed execution can be recorded as failed.
- On Laravel 12, a task skipped by
onOneServeron the losing host emits no skip event. - Concurrent runs appending to the same output file can capture each other's output.
- During a rolling deploy, a host still running the old code can republish the previous cron expression until it stops.
- Sub-minute slots are computed as aligned to the start of the minute.
- Successful runs of sub-minute tasks are not stored as runs, only the last one on the task: a crash during one shows as a missed run, not as an interrupted one.
- A background task whose
after()callback throws is never closed byschedule:finish, so its run shows as interrupted. - A task left out because the application was down is reported as missed when a task of the same tick brings the application back up.
- Identical tasks sharing a mutex but writing to different output files can store each other's output.
- The task list shows at most 1000 tasks.
- Scheduled tasks with the same command, description or closure line share one row, as one task at several times. Jobs of the same class are told apart only by constructor arguments kept in a property of the same name, and objects only by their class.
- The queue
Pendingcard reads the backend now, cached for a few seconds: it has no history. Bus::batch()on thedatabasequeue driver does not fireJobQueued, so thequeuedcounter undercounts batched jobs there.- On SQLite, a worker timeout inside an open database transaction loses the counters of that attempt.
- A worker started directly on the target of a queue forward (
Queue::forward('a', 'b'), worker onb) counts the attempts underb, whilequeuedis counted undera. - Exceptions with their own
report()method, or stopped by an applicationreportablecallback registered earlier (returningfalseor callingstop()), are not recorded. - A manual
Log::error(..., ['exception' => $e])afterreport($e)is skipped as already recorded. - With the schedule module disabled, exceptions and logs of scheduled tasks have the
schedule:runcommand as their source, not the task. - The
source_idof entries from a successful run of a sub-minute task points to no run, since those runs are not stored. - With a
databasecache store, occurrences and log entries are throttled per process only, so several processes can store the same one in a minute: a cache query inside an open transaction could abort it on PostgreSQL. With stancl/tenancy this is often the store in use: see Storage and cache. - With a scope filter, the exception list and page take counts, last seen and message from the occurrences stored in that scope. Occurrences are throttled per exception and scope and pruned after their retention, so these counts are approximate (a lower bound). The sources of an exception are counted across scopes: its page shows them unfiltered.
- Resolving or reopening an exception applies to every scope, even from a page filtered by scope: the status is that of the exception as a whole.
- An exception thrown in the
catch()callback of a queued closure is located in the closure's file, at a wrong line. - Exceptions of queued closures run synchronously (
syncdriver,dispatchSync()) are located at thedispatch()call, not at the throw. - Closures run by
Concurrency::run()with theprocessdriver are not supported: their exceptions are located inartisan.
Requirements
- PHP 8.3+
- Laravel 12.41+ or 13
- MySQL/MariaDB, PostgreSQL or SQLite (SQL Server is not supported)
Installation
You can install the package via composer:
composer require keepsuit/laravel-spyglass
Publish and run the migration, which creates all the Spyglass tables:
php artisan vendor:publish --tag="spyglass-migrations"
php artisan migrate
The tables are created on the connection set by SPYGLASS_DB_CONNECTION (the default connection otherwise). In a multi-tenant application, keep the migration with the central migrations (for example database/migrations, not a tenant migrations path): Spyglass stores every tenant's entries in one place, filterable by scope.
You can publish the config file with:
php artisan vendor:publish --tag="spyglass-config"
The dashboard is served at /spyglass (SPYGLASS_PATH, optionally on SPYGLASS_DOMAIN), behind the viewSpyglass gate. Its assets ship prebuilt in dist/, built by CI on main: there is nothing to publish.
Logs
Spyglass declares a spyglass log channel. Logs are recorded only when that channel is in the stack the application logs to. With the default config/logging.php, set both in .env:
LOG_CHANNEL=stack LOG_STACK=stderr,spyglass
LOG_CHANNEL must be stack: with another channel, for example LOG_CHANNEL=stderr, LOG_STACK is ignored and nothing reaches Spyglass. Keep in LOG_STACK the channels the application already writes to (stderr here, single in the default configuration).
Or list it in the stack channels of a customised config/logging.php:
'stack' => ['driver' => 'stack', 'channels' => ['stderr', 'spyglass']],
Modules
Modules are listed in spyglass.modules, keyed by class, in dashboard order. Each one can be turned off with its SPYGLASS_<MODULE>_ENABLED variable (for example SPYGLASS_LOGS_ENABLED=false). A module missing from a published config file is disabled: after an upgrade that adds a module, copy its entry from the package config to enable it.
Storage and cache
Entries are written through a copy of the storage connection registered as spyglass, so they stay outside the application's transactions: a rollback or a deadlock on either side does not affect the other. On SQLite, which allows a single writer, the connection itself is used. The connection and cache store names are resolved once at boot, so runtime switches of the defaults (for example per-tenant databases) do not affect them.
The cache throttles repeated exceptions and log messages across processes and holds queue sizes for a few seconds. Set SPYGLASS_CACHE_STORE=array to keep it per process. SPYGLASS_CACHE_STORE=null does not disable it: env() reads it as null, which selects the application's default store.
With stancl/tenancy, set SPYGLASS_CACHE_STORE to a store that its CacheTenancyBootstrapper does not separate per tenant. In practice this is often the database store on the central connection, with which the throttle holds per process only (see Known limitations).
Pruning
spyglass:prune deletes entries older than each module's retention and is scheduled daily. To run it on your own schedule, set schedule_prune to false and schedule the command yourself:
Schedule::command('spyglass:prune')->dailyAt('03:00');
Testing
composer test
Dashboard development
The dashboard is a React application in resources/js. CI builds it into dist/ and commits the build on main; pull requests never carry dist/, which is ignored. Build it locally to try a change in an application:
npm install npm run build # or `npm run dev` to rebuild on change npm test
To look at it with demo data for every module, serve the Testbench workbench and open http://localhost:8000/spyglass:
composer serve # builds a SQLite database, seeds it and starts the server composer build # reseeds without restarting: the demo data is relative to now
The workbench lives in workbench/: WorkbenchServiceProvider opens the gate and resolves a tenant scope, DatabaseSeeder writes the demo data. With npm run dev running in another terminal, reloading the page picks up frontend changes.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.