Real-time monitoring for Laravel applications

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
today I want to highlight a thirdparty package that helps you monitor your laravel applications I know I talk a lot about first-party packages but there are even more good thirdparty packages so I'm going to show you laral top as a way to keep track of what's going on in your application real time let's get started I'm going to start by saying laravel new top and we'll do no starter kit no we don't need any of that this is going to download and install LEL for me and create a new project and we'll choose SQL light and we'll change into top and I think it migrates for you yeah there's nothing to migrate after that we're going to composure require uh Lev CZ don't really know how to pronounce that SL laral top so we're going to pull that in and then we can open this in PHP storm and start poking around actually let's go ahead and publish I think it's vendor publish and is there a yeah let's publish whatever they have in there so there is a configuration file which means we can go take a look at some stuff so let's open this in PHP storm and go to the config file and see if there's anything good there um looks like you can change your redus connection or change recording mode um I don't think we're going to do either of those things right now let's go to our EnV file my reddest connection is on 6380 because it's powered by larel herd and so if we open up herd and look we see 6380 so I need to change that to 6380 and I have laral top is a way to monitor some high level stuff about your application including request response time database query time cash hits and misses Etc um the way that it works is it listens to laravel's Native events of which there are many and laral fires these events for a query completed or cash hit or miss or response sent that sort of thing so it listens to all of those and then writes it into reddis and then gives you this command where you can watch it so if you run PHP Artisan top you see that you're sent into this little dashboard so it's continually running but we're not sending any requests yet but if we were to send some requests just to top. test you'll see stuff starting to fly in here this is super cool so you see it's live updating we get requests per second over here um queries cash we're not running any cash yet uh so let's go ahead and add a few things let's come over into web.php and we'll duplicate this guy and call that cash and return uh how do we want to do this let's go ahead and make a key of key Rand between one and 100 and we'll return cash remember member so we'll populate it if it's not there for now plus how many seconds add seconds let's do Rand between I don't know two and 10 seconds and then the call back is going to just be cached so this is going to pull it out of the cache or if it's not there populate it in the cache um and store it for between 2 and 10 seconds so now we should see some cash hits and misses um let's go ahead and not that one this one let's fire that up there again and we can fire it up on Cache as well so we'll see two routes are now being hit and we see the hits and misses are starting to populate over there which this is pretty cool I can see this being extremely useful on a real application let's do a database one as well so here we'll just call this DB and this will be easy we can just say uh DB select select star from users uh semicolon outside simplify uh import sure and we'll just do that so now we'll come back over here and while those are running we will also fire up some hits against the DB route and we should see there's the DB route and the queries there you go they start to fly up this is a very cool way to monitor the web side of your laral application it doesn't monitor cued jobs or commands um but it does write all the data to reddis so if you do have multiple servers multiple web servers this will aggregate all of that data together because it's writing it to a central repository which is reddis um another thing you could use to monitor your application is larel pulse which is a first-party package from the LEL team it is similar and that it Aggregates statistics um but puts it in a web dashboard and also it makes it very easy easy to write your own uh aggregators I have a video on creating a custom pulse card that you can watch here until the next time see you
Info
Channel: Aaron Francis
Views: 10,794
Rating: undefined out of 5
Keywords:
Id: DTEAN5ADfhs
Channel Id: undefined
Length: 5min 11sec (311 seconds)
Published: Fri Jun 07 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.