Get your next remote job on LaraJobs.
1 contributor Edit on GitHub Laravel Packages

Laravel Pulse: monitor your apps for free

Table of contents:

Laravel Pulse: monitor your apps for free

What Laravel Pulse is

Laravel Pulse is a free and open source package for the Laravel framework that helps developers monitor various aspects of their web applications in real-time.

Taylor Otwell, the creator of Laravel, said that the tool was born out of frustration he had with Laravel Forge and its inability to quickly diagnose why the service was underperforming and which users were causing that.

I still can’t believe such a tool can be free, but there we are!

Laravel Pulse’s dashboard in action.

Laravel Pulse release date

Laravel Pulse was released on December 1, 2023 as a beta version.

The features Laravel Pulse offers

  • Application usage of your users: Laravel Pulse lets you see which of your users consume the most resources. It uncovers which ones make the most requests, engage with the slowest endpoints, and dispatch the most jobs throughout your application.
  • Statistics of your servers: Monitor various aspects of your servers, like CPU, memory, and disk usage. All of this in one place!
  • Queue monitoring: Instead of trying to guess which queue needs more resources, make educated decisions based on historical data and bring real benefits to your users. 👌
  • Performance monitoring: Again, making decisions based on data is invaluable, and Laravel Pulse can also help with routes, database queries, jobs, and even outgoing requests.
  • Trending exceptions: It’s like having a highly lightweight error-tracking tool. You will see which exceptions are the most frequent and how they could be related to your performance issues.
  • Custom community-powered metrics: Laravel Pulse will undoubtedly be customizable, and I’ll share whatever I can find from the community here on my blog.
  • Custom dashboard layout: It’s mentionned on the official website that the dashboard’s layout can be customized, which is great news!

Install Laravel Pulse

For now, Laravel Pulse requires a MySQL database. If you are running something else, that’s fine, but you will have to create a new database connection for MySQL.

Pulse is still in beta and you have to make some changes to your composer.json file to install it until a stable version is released. Change the minimum-stability to beta and make sure prefer-stable is set to true:

"minimum-stability": "beta",
"prefer-stable": true

Then, just to install Pulse, use the following command:

composer require laravel/pulse

Set up Laravel Pulse

To set up Laravel Pulse, you will need to ensure it has a database in which it can store the data it collects. You can do this by running the migrations (which you don’t need to publish):

php artisan migrate

Once this is done, open your browser and hit the route /pulse. It was that simple.

Laravel Pulse right after it has been installed.

Let Laravel Pulse monitor your server

Right now, our new installation of Pulse is empty.

We have to display information in there and I suggest we start with your server’s resources.

To do this, run the following command:

php artisan pulse:check

This command runs continuously to provide Pulse with the needed data for its . This is a daemon you have to run in the background, and I recommend you to use Supervisor to do so.

Laravel Pulse’s php artisan pulse:check command in action.

Make Laravel Pulse secure

Securing access to Laravel Pulse can be done in the same way as Laravel Horizon for instance. In your AuthServiceProvider, define a viewPulse Gate and do whatever check is necessary. In my case, I check for the correct email address:

namespace App\Providers;
 
use App\Models\User;
use Illuminate\Support\Facades\Gate;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
 
class AuthServiceProvider extends ServiceProvider
{
public function boot() : void
{
Gate::define('viewPulse', fn (User $user) => in_array($user->email, [
'johndoe@example.com',
]));
}
}

Contribute to Laravel Pulse

Laravel Pulse’s is free, open source, and is available through a GitHub repository at laravel/pulse. You can send as many Pull Requests as you want for bug fixes and enhancements.

Laravel Pulse’s GitHub repository.

Laravel Pulse troubleshooting

Laravel Pulse returns a 404 not found error

For anyone having a 404 after installing Laravel Pulse, here’s a potential solution: You may have a wildcard highjacking the pulse route.

Here are possible fixes:

  • Change the path configuration value in config/pulse.php to something like /pulse/dashboard.
  • Or a more elegant solution would be to filter your wildcard route like so (which is what I did for this blog):
Route::get('/{post:slug}', [PostController::class, 'show'])->name('posts.show')
->where('post', '^(?!pulse$).*$');

Basically, we are instructing Laravel to match the route only if it isn’t pulse.

My Laravel Pulse dashboard is empty

If your Laravel Pulse dashboard is empty, chances are that there’s a problem with Livewire. If you open your developer tools and check for errors, you will most likely see a 404 not found error on /livewire/livewire.js. Luckily, I wrote about this recurring issue caused by how Livewire serves its JavaScript by default: Fix the /livewire/livewire.js 404 not found error

Benjamin Crozat

Written by Benjamin Crozat

Indie hacker, blogger, and AI enthusiast building things with the TALL stack. 🔥

Follow me on:

Recommended articles

20+ Laravel best practices, tips and tricks to use in 2023 20+ Laravel best practices, tips and tricks to use in 2023

Learning a framework can be overwhelming, but time and execution will make you a master. Here are some best practices to help you toward your goal.

Modified on Oct 17, 2023

Laravel 10 is out! Here are every new features and changes. Laravel 10 is out! Here are every new features and changes.

Laravel 10 has been released on February 14, 2023. Let's dive into every relevant new features and changes.

Modified on Nov 2, 2023

Laravel interview questions and answers for 2023 Laravel interview questions and answers for 2023

Nailing a Laravel job interview can be a daunting task, but with the right preparation and mindset, you can set yourself up for success.

Modified on Sep 19, 2023 Audio available

Laravel 10: the upgrade guide from version 9 Laravel 10: the upgrade guide from version 9

I show you how to upgrade your Laravel 9 project to version 10 and help you decide whether the return on investment is worth it.

Modified on Nov 2, 2023

12 Laravel security best practices for 2023 12 Laravel security best practices for 2023

Secure your Laravel app: protect sensitive files, keep your packages and Laravel updated, use policies, validate input, and more.

Modified on Sep 5, 2023

Gold sponsors New

  • Wire Elements
    Beautiful handcrafted Livewire components.
    Check site
Your business here

Partners

If you buy from one of my partners below, I will be compensated at no cost to you. These are services I use or used, and 100% stand behind.

  • Scalable and reliable VPS hosting.
    Bonus: $200 of free credits
    Check site
  • The Google Analytics alternative without compromise.
    Free trial: 30 days
    Bonus: $10 off your first invoice
    Check site
  • Flare
    Track PHP and JavaScript errors in one place.
    Free trial: 10 days
    Check site
  • Keep track of your Google rankings.
    Free trial: 7 days
    Promo code: WELCOME30
    Check site
- / -