Filament Storage Monitor: Track Disk Usage From Your Filament Dashboard
Composer Pacakge Filament #Filament #Laravel #PHP #Dashboard Widget #Server Monitoring #Open Source

Filament Storage Monitor: Track Disk Usage From Your Filament Dashboard

3 min read Mohamed Said Mohamed Said

Monitor Server Disk Usage Directly in Your Filament Panel

Filament Storage Monitor is a community plugin that embeds a disk-usage widget into any Filament admin panel. Rather than reaching for an external monitoring tool, you can surface storage stats—powered by native PHP filesystem functions—right alongside the rest of your dashboard.

Registering Disks

You register the plugin inside your panel's ->plugins() call. Two convenience methods cover the most common cases:

  • addDisk(path, label) — watches any absolute filesystem path.
  • laravelDisk(name, label) — resolves a disk defined in config/filesystems.php.
use AchyutN\FilamentStorageMonitor\FilamentStorageMonitor;

return $panel
    ->plugins([
        FilamentStorageMonitor::make()
            ->addDisk('/mnt/data', label: 'Data Partition')
            ->laravelDisk(name: 'public', label: 'Media Storage'),
    ]);

For richer customization, the add() method accepts a Disk DTO where you can attach a Filament color and a Heroicon to each entry:

use AchyutN\FilamentStorageMonitor\DTO\Disk;
use AchyutN\FilamentStorageMonitor\FilamentStorageMonitor;
use Filament\Support\Colors\Color;
use Filament\Support\Icons\Heroicon;

FilamentStorageMonitor::make()
    ->add(
        Disk::make('web-root')
            ->path('/var/www/html')
            ->label('Web Root')
            ->color(Color::Green)
            ->icon(Heroicon::ComputerDesktop),
    )
    ->addDisk(
        path: '/mnt/backup',
        label: 'Backups',
        color: Color::Blue,
        icon: Heroicon::ArchiveBox,
    );

Per-Disk Authorization

Disk usage data can be sensitive, so the plugin provides two authorization layers:

  • A visible() closure on the plugin hides the entire widget when it returns false.
  • An isVisible closure on an individual disk hides only that entry.
FilamentStorageMonitor::make()
    ->visible(fn () => auth()->user()->is_admin)
    ->addDisk(
        path: '/var/www/html',
        label: 'App Files',
        isVisible: fn () => auth()->user()->can('view_server_stats')
    );

Compact Mode

If dashboard real estate is tight, compact mode strips each disk entry down to its label and remaining free space:

FilamentStorageMonitor::make()
    ->compact();

The widget also respects the standard Filament layout helpers—columnSpan(), columnStart(), sort(), and lazy()—so it slots cleanly into any grid arrangement.

Error Handling

By default, an unresolvable path (a missing mount point, for example) is caught silently and the widget continues to render. During development you may want exceptions to surface instead:

FilamentStorageMonitor::make()
    ->throwException(fn () => app()->isLocal());

Passing a closure lets you enable strict behavior only in local environments without touching production.

Known Limitation

Because the plugin reads partition-level stats via PHP's filesystem functions, two paths that live on the same partition will report identical total and free space figures. Per-directory size calculation is on the roadmap for a future release.

Key Takeaways

  • Register any filesystem path or Laravel disk with addDisk() / laravelDisk().
  • Use the Disk DTO for per-disk colors and Heroicons.
  • Gate visibility at the widget level or per individual disk with closures.
  • Compact mode reduces each entry to label + free space.
  • Silent error handling by default; opt into exceptions per environment.
  • Partition-level stats mean two paths on the same partition share the same numbers.

The source code, documentation, and contribution guidelines are available on GitHub.


Source: Laravel News — Filament Storage Monitor

Found this useful?

Frequently Asked Questions

3 questions
Q01 Can I monitor multiple disks or partitions with Filament Storage Monitor?
Yes. You can chain multiple `addDisk()` or `laravelDisk()` calls, or use the `Disk` DTO with `add()`, to register as many paths as you need. Note that two paths on the same partition will report the same total and free space because the plugin reads partition-level stats.
Q02 How do I restrict who can see disk usage data in the Filament widget?
Use the `visible()` closure on the plugin to hide the entire widget based on any condition, and the `isVisible` closure on an individual disk entry to hide just that row. Both closures receive the standard Laravel auth context, so you can check roles or permissions as usual.
Q03 What happens if a registered path does not exist or cannot be read?
By default the plugin catches the error silently and continues rendering the rest of the widget. You can call `throwException()` (optionally with a closure scoped to local environments) to re-enable exceptions when you want failures to surface during development.

Continue reading

More Articles

View all