Install Laravel Pulse0:00
Now that we have a working chat app and we have it deployed to a public place on the internet where people can access it, we probably want to think about monitoring our reverb server, getting an understanding of how many users are connected and how many messages are passing through. And we can do that with our first-party integration with Laravel Pulse. So here in our terminal, we're going to start by installing Laravel Pulse with composer require laravel-pulse. Once that's installed, we're going to publish the vendor files that ship with Pulse with php artisan vendor:publish. And then we're going to search for Pulse in here and we're going to publish everything.
php artisan vendor:publish. And then we're going to search for Pulse in here and we're going to publish everything from the PulseServiceProvider. Great. And there's one more step here. We just need to run migration. So we can say php artisan migrate. Everything done. So if we jump over into our browser and hit the /Pulse endpoint, we should have our Pulse dashboard up and running.
Access Pulse Dashboard1:00
So if we jump over into our browser and hit the slash Pulse endpoint, we should have our Pulse dashboard up and running. And there it is. So this is all of the stock metrics which ship with Pulse. And we're going to add a couple to here. We're going to add a card which allows us to track the number of connections and another one which allows us to track the number of messages. Okay. Here in the docs, you can see that we need to register two recorders with our Pulse configuration. So we can do that in the recorders section of our Pulse.php configuration file.
Register Reverb Recorders1:17
Here in the docs, you can see that we need to register two recorders with our Pulse configuration. So we can do that in the recorders section of our Pulse.php configuration file. We're going to take these two and drop them straight in. Okay. Here we are in the recorders section of our configuration. So like I said, we're just going to scroll down and drop these two in here. And obviously we want to import these. Let's do reverbConnections and reverbMessages. Those two entries are going to mean that we're going to start collecting entries about the number of connections and the number of messages.
Add Livewire Dashboard Cards1:44
Those two entries are going to mean that we're going to start collecting entries about the number of connections and the number of messages. But we also want to show those on the front end in our dashboard. So let's jump back into our docs and see what we need to do next. Okay. So here you can see that we need to add two components, two Livewire components to our Pulse dashboard. So let's go and copy these. And we'll jump back over into the dashboard blade component within our application. Here we are in the vendor pulse dashboard.blade.php file.
And we'll jump back over into the dashboard.blade.php component within our application. Here we are in the vendor/pulse/dashboard.blade.php file. And we're going to simply drop those two components in here. And we're going to have those components full width by passing this cols="full" attribute. So if we jump back into our Pulse dashboard now, we should see those components are rendering. Okay. And here they are, but no results yet because we're not actually collecting any data. And that's because there's two final things that we need to do. We need to start our reverb server. Now that Pulse is installed, reverb is going to know that it needs to start collecting.
Start Reverb and Pulse Check2:33
We need to start our reverb server. Now that Pulse is installed, reverb is going to know that it needs to start collecting those metrics. And that will start to happen behind the scenes just by starting the server. We also need to run the Pulse check command, which will check for new Pulse events. Okay. So we're going to start by starting reverb, PA reverb start. And we're going to open another terminal and we're going to say PA Pulse check. Here we are in our application. We now need to start firing some messages across our WebSocket server.
Generate Traffic and Verify Metrics2:57
Here we are in our application. We now need to start firing some messages across our WebSocket server. We already have a connection. So let's reconnect, refresh and make sure that connection is still valid. And we're going to start sending a few messages in here. So we're going to say, hello. Are we collecting metrics, collecting metrics, let's jump back over into Pulse and see what we've got. Okay. So you can see now that these dashboards are starting to populate.
Okay. So you can see now that these dashboards are starting to populate. We have this ID up here is the reverb application ID, which you can see in your configuration. And this is saying that we currently have one connection established. And currently we've sent eight messages across our WebSocket server. So if I jump back into the chat application and send a few more messages, we should see that number increase. I'm also going to jump into this browser and log in as James and we'll send a few more messages. We'll say, hey, Joe.
messages. We'll say, hey, Joe. And now we should have an extra connection established. You can see now that we have two connections. We're able to see the average connection for the time window as well. And similarly, with messages, we're able to see the number of messages sent, number of messages sent per second, number of messages received, and the number of messages received per second. So this is a really nice first party integration with Laravel Pulse to give you a real snapshot indicator of what's happening with your reverb server at any given time.
So this is a really nice first party integration with Laravel Pulse to give you a real snapshot indicator of what's happening with your reverb server at any given time.
