# Laravel Pulse * Introduction * Installation * Configuration * Dashboard * Authorization * Customization * Resolving Users * Cards * Capturing Entries * Recorders * Filtering * Performance * Using a Different Database * Redis Ingest * Sampling * Trimming * Handling Pulse Exceptions * Custom Cards * Card Components * Styling * Data Capture and Aggregation ## Introduction [Laravel Pulse](https://github.com/laravel/pulse) delivers at-a-glance insights into your application's performance and usage. With Pulse, you can track down bottlenecks like slow jobs and endpoints, find your most active users, and more. For in-depth debugging of individual events, check out [Laravel Telescope](/docs/12.x/telescope). ## Installation Pulse's first-party storage implementation currently requires a MySQL, MariaDB, or PostgreSQL database. If you are using a different database engine, you will need a separate MySQL, MariaDB, or PostgreSQL database for your Pulse data. You may install Pulse using the Composer package manager: 1composer require laravel/pulse composer require laravel/pulse Next, you should publish the Pulse configuration and migration files using the `vendor:publish` Artisan command: 1php artisan vendor:publish --provider="Laravel\Pulse\PulseServiceProvider" php artisan vendor:publish --provider="Laravel\Pulse\PulseServiceProvider" Finally, you should run the `migrate` command in order to create the tables needed to store Pulse's data: 1php artisan migrate php artisan migrate Once Pulse's database migrations have been run, you may access the Pulse dashboard via the `/pulse` route. If you do not want to store Pulse data in your application's primary database, you may specify a dedicated database connection. ### Configuration Many of Pulse's configuration options can be controlled using environment variables. To see the available options, register new recorders, or configure advanced options, you may publish the `config/pulse.php` configuration file: 1php artisan vendor:publish --tag=pulse-config php artisan vendor:publish --tag=pulse-config ## Dashboard ### Authorization The Pulse dashboard may be accessed via the `/pulse` route. By default, you will only be able to access this dashboard in the `local` environment, so you will need to configure authorization for your production environments by customizing the `'viewPulse'` authorization gate. You can accomplish this within your application's `app/Providers/AppServiceProvider.php` file: 1use App\Models\User; 2use Illuminate\Support\Facades\Gate; 3  4/** 5 * Bootstrap any application services. 6 */ 7public function boot(): void 8{ 9 Gate::define('viewPulse', function (User $user) { 10 return $user->isAdmin(); 11 }); 12  13 // ... 14} use App\Models\User; use Illuminate\Support\Facades\Gate; /** * Bootstrap any application services. */ public function boot(): void { Gate::define('viewPulse', function (User $user) { return $user->isAdmin(); }); // ... } ### Customization The Pulse dashboard cards and layout may be configured by publishing the dashboard view. The dashboard view will be published to `resources/views/vendor/pulse/dashboard.blade.php`: 1php artisan vendor:publish --tag=pulse-dashboard php artisan vendor:publish --tag=pulse-dashboard The dashboard is powered by [Livewire](https://livewire.laravel.com/), and allows you to customize the cards and layout without needing to rebuild any JavaScript assets. Within this file, the `` component is responsible for rendering the dashboard and provides a grid layout for the cards. If you would like the dashboard to span the full width of the screen, you may provide the `full- width` prop to the component: 1 2 ... 3 ... By default, the `` component will create a 12 column grid, but you may customize this using the `cols` prop: 1 2 ... 3 ... Each card accepts a `cols` and `rows` prop to control the space and positioning: 1 Most cards also accept an `expand` prop to show the full card instead of scrolling: 1 ### Resolving Users For cards that display information about your users, such as the Application Usage card, Pulse will only record the user's ID. When rendering the dashboard, Pulse will resolve the `name` and `email` fields from your default `Authenticatable` model and display avatars using the Gravatar web service. You may customize the fields and avatar by invoking the `Pulse::user` method within your application's `App\Providers\AppServiceProvider` class. The `user` method accepts a closure which will receive the `Authenticatable` model to be displayed and should return an array containing `name`, `extra`, and `avatar` information for the user: 1use Laravel\Pulse\Facades\Pulse; 2  3/** 4 * Bootstrap any application services. 5 */ 6public function boot(): void 7{ 8 Pulse::user(fn ($user) => [ 9 'name' => $user->name, 10 'extra' => $user->email, 11 'avatar' => $user->avatar_url, 12 ]); 13  14 // ... 15} use Laravel\Pulse\Facades\Pulse; /** * Bootstrap any application services. */ public function boot(): void { Pulse::user(fn ($user) => [ 'name' => $user->name, 'extra' => $user->email, 'avatar' => $user->avatar_url, ]); // ... } You may completely customize how the authenticated user is captured and retrieved by implementing the `Laravel\Pulse\Contracts\ResolvesUsers` contract and binding it in Laravel's [service container](/docs/12.x/container#binding- a-singleton). ### Cards #### Servers The `` card displays system resource usage for all servers running the `pulse:check` command. Please refer to the documentation regarding the servers recorder for more information on system resource reporting. If you replace a server in your infrastructure, you may wish to stop displaying the inactive server in the Pulse dashboard after a given duration. You may accomplish this using the `ignore-after` prop, which accepts the number of seconds after which inactive servers should be removed from the Pulse dashboard. Alternatively, you may provide a relative time formatted string, such as `1 hour` or `3 days and 1 hour`: 1 #### Application Usage The `` card displays the top 10 users making requests to your application, dispatching jobs, and experiencing slow requests. If you wish to view all usage metrics on screen at the same time, you may include the card multiple times and specify the `type` attribute: 1 2 3 To learn how to customize how Pulse retrieves and displays user information, consult our documentation on resolving users. If your application receives a lot of requests or dispatches a lot of jobs, you may wish to enable sampling. See the user requests recorder, user jobs recorder, and slow jobs recorder documentation for more information. #### Exceptions The `` card shows the frequency and recency of exceptions occurring in your application. By default, exceptions are grouped based on the exception class and location where it occurred. See the exceptions recorder documentation for more information. #### Queues The `` card shows the throughput of the queues in your application, including the number of jobs queued, processing, processed, released, and failed. See the queues recorder documentation for more information. #### Slow Requests The `` card shows incoming requests to your application that exceed the configured threshold, which is 1,000ms by default. See the slow requests recorder documentation for more information. #### Slow Jobs The `` card shows the queued jobs in your application that exceed the configured threshold, which is 1,000ms by default. See the slow jobs recorder documentation for more information. #### Slow Queries The `` card shows the database queries in your application that exceed the configured threshold, which is 1,000ms by default. By default, slow queries are grouped based on the SQL query (without bindings) and the location where it occurred, but you may choose to not capture the location if you wish to group solely on the SQL query. If you encounter rendering performance issues due to extremely large SQL queries receiving syntax highlighting, you may disable highlighting by adding the `without-highlighting` prop: 1 See the slow queries recorder documentation for more information. #### Slow Outgoing Requests The `` card shows outgoing requests made using Laravel's [HTTP client](/docs/12.x/http-client) that exceed the configured threshold, which is 1,000ms by default. By default, entries will be grouped by the full URL. However, you may wish to normalize or group similar outgoing requests using regular expressions. See the slow outgoing requests recorder documentation for more information. #### Cache The `` card shows the cache hit and miss statistics for your application, both globally and for individual keys. By default, entries will be grouped by key. However, you may wish to normalize or group similar keys using regular expressions. See the cache interactions recorder documentation for more information. ## Capturing Entries Most Pulse recorders will automatically capture entries based on framework events dispatched by Laravel. However, the servers recorder and some third- party cards must poll for information regularly. To use these cards, you must run the `pulse:check` daemon on all of your individual application servers: 1php artisan pulse:check php artisan pulse:check To keep the `pulse:check` process running permanently in the background, you should use a process monitor such as Supervisor to ensure that the command does not stop running. As the `pulse:check` command is a long-lived process, it will not see changes to your codebase without being restarted. You should gracefully restart the command by calling the `pulse:restart` command during your application's deployment process: 1php artisan pulse:restart php artisan pulse:restart Pulse uses the [cache](/docs/12.x/cache) to store restart signals, so you should verify that a cache driver is properly configured for your application before using this feature. ### Recorders Recorders are responsible for capturing entries from your application to be recorded in the Pulse database. Recorders are registered and configured in the `recorders` section of the Pulse configuration file. #### Cache Interactions The `CacheInteractions` recorder captures information about the [cache](/docs/12.x/cache) hits and misses occurring in your application for display on the Cache card. You may optionally adjust the sample rate and ignored key patterns. You may also configure key grouping so that similar keys are grouped as a single entry. For example, you may wish to remove unique IDs from keys caching the same type of information. Groups are configured using a regular expression to "find and replace" parts of the key. An example is included in the configuration file: 1Recorders\CacheInteractions::class => [ 2 // ... 3 'groups' => [ 4 // '/:\d+/' => ':*', 5 ], 6], Recorders\CacheInteractions::class => [ // ... 'groups' => [ // '/:\d+/' => ':*', ], ], The first pattern that matches will be used. If no patterns match, then the key will be captured as-is. #### Exceptions The `Exceptions` recorder captures information about reportable exceptions occurring in your application for display on the Exceptions card. You may optionally adjust the sample rate and ignored exceptions patterns. You may also configure whether to capture the location that the exception originated from. The captured location will be displayed on the Pulse dashboard which can help to track down the exception origin; however, if the same exception occurs in multiple locations then it will appear multiple times for each unique location. #### Queues The `Queues` recorder captures information about your applications queues for display on the Queues. You may optionally adjust the sample rate and ignored jobs patterns. #### Slow Jobs The `SlowJobs` recorder captures information about slow jobs occurring in your application for display on the Slow Jobs card. You may optionally adjust the slow job threshold, sample rate, and ignored job patterns. You may have some jobs that you expect to take longer than others. In those cases, you may configure per-job thresholds: 1Recorders\SlowJobs::class => [ 2 // ... 3 'threshold' => [ 4 '#^App\\Jobs\\GenerateYearlyReports$#' => 5000, 5 'default' => env('PULSE_SLOW_JOBS_THRESHOLD', 1000), 6 ], 7], Recorders\SlowJobs::class => [ // ... 'threshold' => [ '#^App\\Jobs\\GenerateYearlyReports$#' => 5000, 'default' => env('PULSE_SLOW_JOBS_THRESHOLD', 1000), ], ], If no regular expression patterns match the job's classname, then the `'default'` value will be used. #### Slow Outgoing Requests The `SlowOutgoingRequests` recorder captures information about outgoing HTTP requests made using Laravel's [HTTP client](/docs/12.x/http-client) that exceed the configured threshold for display on the Slow Outgoing Requests card. You may optionally adjust the slow outgoing request threshold, sample rate, and ignored URL patterns. You may have some outgoing requests that you expect to take longer than others. In those cases, you may configure per-request thresholds: 1Recorders\SlowOutgoingRequests::class => [ 2 // ... 3 'threshold' => [ 4 '#backup.zip$#' => 5000, 5 'default' => env('PULSE_SLOW_OUTGOING_REQUESTS_THRESHOLD', 1000), 6 ], 7], Recorders\SlowOutgoingRequests::class => [ // ... 'threshold' => [ '#backup.zip$#' => 5000, 'default' => env('PULSE_SLOW_OUTGOING_REQUESTS_THRESHOLD', 1000), ], ], If no regular expression patterns match the request's URL, then the `'default'` value will be used. You may also configure URL grouping so that similar URLs are grouped as a single entry. For example, you may wish to remove unique IDs from URL paths or group by domain only. Groups are configured using a regular expression to "find and replace" parts of the URL. Some examples are included in the configuration file: 1Recorders\SlowOutgoingRequests::class => [ 2 // ... 3 'groups' => [ 4 // '#^https://api\.github\.com/repos/.*$#' => 'api.github.com/repos/*', 5 // '#^https?://([^/]*).*$#' => '\1', 6 // '#/\d+#' => '/*', 7 ], 8], Recorders\SlowOutgoingRequests::class => [ // ... 'groups' => [ // '#^https://api\.github\.com/repos/.*$#' => 'api.github.com/repos/*', // '#^https?://([^/]*).*$#' => '\1', // '#/\d+#' => '/*', ], ], The first pattern that matches will be used. If no patterns match, then the URL will be captured as-is. #### Slow Queries The `SlowQueries` recorder captures any database queries in your application that exceed the configured threshold for display on the Slow Queries card. You may optionally adjust the slow query threshold, sample rate, and ignored query patterns. You may also configure whether to capture the query location. The captured location will be displayed on the Pulse dashboard which can help to track down the query origin; however, if the same query is made in multiple locations then it will appear multiple times for each unique location. You may have some queries that you expect to take longer than others. In those cases, you may configure per-query thresholds: 1Recorders\SlowQueries::class => [ 2 // ... 3 'threshold' => [ 4 '#^insert into `yearly_reports`#' => 5000, 5 'default' => env('PULSE_SLOW_QUERIES_THRESHOLD', 1000), 6 ], 7], Recorders\SlowQueries::class => [ // ... 'threshold' => [ '#^insert into `yearly_reports`#' => 5000, 'default' => env('PULSE_SLOW_QUERIES_THRESHOLD', 1000), ], ], If no regular expression patterns match the query's SQL, then the `'default'` value will be used. #### Slow Requests The `Requests` recorder captures information about requests made to your application for display on the Slow Requests and Application Usage cards. You may optionally adjust the slow route threshold, sample rate, and ignored paths. You may have some requests that you expect to take longer than others. In those cases, you may configure per-request thresholds: 1Recorders\SlowRequests::class => [ 2 // ... 3 'threshold' => [ 4 '#^/admin/#' => 5000, 5 'default' => env('PULSE_SLOW_REQUESTS_THRESHOLD', 1000), 6 ], 7], Recorders\SlowRequests::class => [ // ... 'threshold' => [ '#^/admin/#' => 5000, 'default' => env('PULSE_SLOW_REQUESTS_THRESHOLD', 1000), ], ], If no regular expression patterns match the request's URL, then the `'default'` value will be used. #### Servers The `Servers` recorder captures CPU, memory, and storage usage of the servers that power your application for display on the Servers card. This recorder requires the pulse:check command to be running on each of the servers you wish to monitor. Each reporting server must have a unique name. By default, Pulse will use the value returned by PHP's `gethostname` function. If you wish to customize this, you may set the `PULSE_SERVER_NAME` environment variable: 1PULSE_SERVER_NAME=load-balancer PULSE_SERVER_NAME=load-balancer The Pulse configuration file also allows you to customize the directories that are monitored. #### User Jobs The `UserJobs` recorder captures information about the users dispatching jobs in your application for display on the Application Usage card. You may optionally adjust the sample rate and ignored job patterns. #### User Requests The `UserRequests` recorder captures information about the users making requests to your application for display on the Application Usage card. You may optionally adjust the sample rate and ignored URL patterns. ### Filtering As we have seen, many recorders offer the ability to, via configuration, "ignore" incoming entries based on their value, such as a request's URL. But, sometimes it may be useful to filter out records based on other factors, such as the currently authenticated user. To filter out these records, you may pass a closure to Pulse's `filter` method. Typically, the `filter` method should be invoked within the `boot` method of your application's `AppServiceProvider`: 1use Illuminate\Support\Facades\Auth; 2use Laravel\Pulse\Entry; 3use Laravel\Pulse\Facades\Pulse; 4use Laravel\Pulse\Value; 5  6/** 7 * Bootstrap any application services. 8 */ 9public function boot(): void 10{ 11 Pulse::filter(function (Entry|Value $entry) { 12 return Auth::user()->isNotAdmin(); 13 }); 14  15 // ... 16} use Illuminate\Support\Facades\Auth; use Laravel\Pulse\Entry; use Laravel\Pulse\Facades\Pulse; use Laravel\Pulse\Value; /** * Bootstrap any application services. */ public function boot(): void { Pulse::filter(function (Entry|Value $entry) { return Auth::user()->isNotAdmin(); }); // ... } ## Performance Pulse has been designed to drop into an existing application without requiring any additional infrastructure. However, for high-traffic applications, there are several ways of removing any impact Pulse may have on your application's performance. ### Using a Different Database For high-traffic applications, you may prefer to use a dedicated database connection for Pulse to avoid impacting your application database. You may customize the [database connection](/docs/12.x/database#configuration) used by Pulse by setting the `PULSE_DB_CONNECTION` environment variable. 1PULSE_DB_CONNECTION=pulse PULSE_DB_CONNECTION=pulse ### Redis Ingest The Redis Ingest requires Redis 6.2 or greater and `phpredis` or `predis` as the application's configured Redis client driver. By default, Pulse will store entries directly to the configured database connection after the HTTP response has been sent to the client or a job has been processed; however, you may use Pulse's Redis ingest driver to send entries to a Redis stream instead. This can be enabled by configuring the `PULSE_INGEST_DRIVER` environment variable: 1PULSE_INGEST_DRIVER=redis PULSE_INGEST_DRIVER=redis Pulse will use your default [Redis connection](/docs/12.x/redis#configuration) by default, but you may customize this via the `PULSE_REDIS_CONNECTION` environment variable: 1PULSE_REDIS_CONNECTION=pulse PULSE_REDIS_CONNECTION=pulse When using the Redis ingest driver, your Pulse installation should always use a different Redis connection than your Redis powered queue, if applicable. When using the Redis ingest, you will need to run the `pulse:work` command to monitor the stream and move entries from Redis into Pulse's database tables. 1php artisan pulse:work php artisan pulse:work To keep the `pulse:work` process running permanently in the background, you should use a process monitor such as Supervisor to ensure that the Pulse worker does not stop running. As the `pulse:work` command is a long-lived process, it will not see changes to your codebase without being restarted. You should gracefully restart the command by calling the `pulse:restart` command during your application's deployment process: 1php artisan pulse:restart php artisan pulse:restart Pulse uses the [cache](/docs/12.x/cache) to store restart signals, so you should verify that a cache driver is properly configured for your application before using this feature. ### Sampling By default, Pulse will capture every relevant event that occurs in your application. For high-traffic applications, this can result in needing to aggregate millions of database rows in the dashboard, especially for longer time periods. You may instead choose to enable "sampling" on certain Pulse data recorders. For example, setting the sample rate to `0.1` on the User Requests recorder will mean that you only record approximately 10% of the requests to your application. In the dashboard, the values will be scaled up and prefixed with a `~` to indicate that they are an approximation. In general, the more entries you have for a particular metric, the lower you can safely set the sample rate without sacrificing too much accuracy. ### Trimming Pulse will automatically trim its stored entries once they are outside of the dashboard window. Trimming occurs when ingesting data using a lottery system which may be customized in the Pulse configuration file. ### Handling Pulse Exceptions If an exception occurs while capturing Pulse data, such as being unable to connect to the storage database, Pulse will silently fail to avoid impacting your application. If you wish to customize how these exceptions are handled, you may provide a closure to the `handleExceptionsUsing` method: 1use Laravel\Pulse\Facades\Pulse; 2use Illuminate\Support\Facades\Log; 3  4Pulse::handleExceptionsUsing(function ($e) { 5 Log::debug('An exception happened in Pulse', [ 6 'message' => $e->getMessage(), 7 'stack' => $e->getTraceAsString(), 8 ]); 9}); use Laravel\Pulse\Facades\Pulse; use Illuminate\Support\Facades\Log; Pulse::handleExceptionsUsing(function ($e) { Log::debug('An exception happened in Pulse', [ 'message' => $e->getMessage(), 'stack' => $e->getTraceAsString(), ]); }); ## Custom Cards Pulse allows you to build custom cards to display data relevant to your application's specific needs. Pulse uses [Livewire](https://livewire.laravel.com), so you may want to [review its documentation](https://livewire.laravel.com/docs) before building your first custom card. ### Card Components Creating a custom card in Laravel Pulse starts with extending the base `Card` Livewire component and defining a corresponding view: 1namespace App\Livewire\Pulse; 2  3use Laravel\Pulse\Livewire\Card; 4use Livewire\Attributes\Lazy; 5  6#[Lazy] 7class TopSellers extends Card 8{ 9 public function render() 10 { 11 return view('livewire.pulse.top-sellers'); 12 } 13} namespace App\Livewire\Pulse; use Laravel\Pulse\Livewire\Card; use Livewire\Attributes\Lazy; #[Lazy] class TopSellers extends Card { public function render() { return view('livewire.pulse.top-sellers'); } } When using Livewire's [lazy loading](https://livewire.laravel.com/docs/lazy) feature, The `Card` component will automatically provide a placeholder that respects the `cols` and `rows` attributes passed to your component. When writing your Pulse card's corresponding view, you may leverage Pulse's Blade components for a consistent look and feel: 1 2 3 4 ... 5 6 7  8 9 ... 10 11 ... ... The `$cols`, `$rows`, `$class`, and `$expand` variables should be passed to their respective Blade components so the card layout may be customized from the dashboard view. You may also wish to include the `wire:poll.5s=""` attribute in your view to have the card automatically update. Once you have defined your Livewire component and template, the card may be included in your dashboard view: 1 2 ... 3  4 5 ... If your card is included in a package, you will need to register the component with Livewire using the `Livewire::component` method. ### Styling If your card requires additional styling beyond the classes and components included with Pulse, there are a few options for including custom CSS for your cards. #### Laravel Vite Integration If your custom card lives within your application's code base and you are using Laravel's [Vite integration](/docs/12.x/vite), you may update your `vite.config.js` file to include a dedicated CSS entry point for your card: 1laravel({ 2 input: [ 3 'resources/css/pulse/top-sellers.css', 4 // ... 5 ], 6}), laravel({ input: [ 'resources/css/pulse/top-sellers.css', // ... ], }), You may then use the `@vite` Blade directive in your dashboard view, specifying the CSS entrypoint for your card: 1 2 @vite('resources/css/pulse/top-sellers.css') 3  4 ... 5 @vite('resources/css/pulse/top-sellers.css') ... #### CSS Files For other use cases, including Pulse cards contained within a package, you may instruct Pulse to load additional stylesheets by defining a `css` method on your Livewire component that returns the file path to your CSS file: 1class TopSellers extends Card 2{ 3 // ... 4  5 protected function css() 6 { 7 return __DIR__.'/../../dist/top-sellers.css'; 8 } 9} class TopSellers extends Card { // ... protected function css() { return __DIR__.'/../../dist/top-sellers.css'; } } When this card is included on the dashboard, Pulse will automatically include the contents of this file within a `