Sunday, May 19, 2024
HomePHPUtilizing Scout APM to Monitor a Laravel Software

Utilizing Scout APM to Monitor a Laravel Software


Scout APM is a Laravel utility efficiency monitoring instrument that ties efficiency anomalies on to endpoints, saving builders hours of time spent on troubleshooting and debugging.

Scout not too long ago expanded its service choices to incorporate microservices and managed service monitoring for PHP functions, providing you with extra cohesive and actionable observability metrics. Be taught extra about easy methods to monitor a laravel utility with Scout APM by studying under.

Setup

To get began monitoring your Laravel functions you’ll initially want a Scout account. When you don’t have one already, you possibly can join a free 14-day free trial (no bank card required) right here.

The following factor to do is so as to add the low-overhead monitoring agent to your mission’s dependencies, this may be carried out with a single command in your shell:

1composer require scoutapp/scout-apm-laravel

This command will set up two packages: scout-apm-laravel and scout-apm-php.
The following factor to do is to outline some configurations settings to hyperlink the agent to your account. To do this, open up your mission’s .env file in your favorite textual content editor and add the next three strains to the top of the file:

1SCOUT_MONITOR=true

2SCOUT_KEY=”enter your Agent Key right here”

3SCOUT_NAME=”enter the title of you utility right here”

You will discover your account’s Agent Key on the settings web page of Scout.
And that’s it! Deploy, and after roughly 5 minutes, your information will begin to seem in Scout. For extra details about Heroku installs or to troubleshoot set up issues, both check out the documentation or shoot an e-mail to assist@scoutapm.com and we’ll be joyful to assist.

The place to start out?

So that you’ve created a Scout account, connected the monitoring agent, however the place do you begin with diagnosing your utility’s efficiency points? Let’s check out the primary options of Scout which may help you to grasp your efficiency points rapidly.

The principle overview web page

The primary web page that you’re introduced with while you log into Scout is the overview web page (proven under) which supplies you a transparent, clutter-free, snapshot of the well being and efficiency of your utility in a single fast look.

The chart is very configurable, permitting you to alter the time interval and toggle which metrics you need to see. It additionally incorporates a neat drag-and-drop instrument (proven under) that permits you to draw a field round areas you would like you discover in additional element. A pop-up window will dynamically load as you draw these bins, displaying all of the endpoints that had been accessed throughout this time interval. This may be significantly helpful while you see a efficiency spike on the chart and also you need to see what brought on it.

Insights tabs

An incredible place to start out in case you are attempting out Scout for the primary time are the insights tabs. Right here we have now a set of algorithms which analyze your mission to determine potential n+1 queries and gradual queries. These give you the “low-hanging fruit” of efficiency fixes that may typically immediately enhance your utility’s efficiency.

Endpoints and Traces

Scout primarily offers utility efficiency metrics at two ranges. Initially, from the attitude of an Endpoint. For instance, on common, how lengthy does this endpoint take to entry and what’s the breakdown of the place time was spent?

When you check out the screenshot under, you possibly can clearly see that on the three events that this ForgetPasswordController endpoint was accessed 78% of the two,371ms imply request time was spent within the controller layer indicating that may be the primary place to analyze if we needed to attempt to enhance this sluggish endpoint.

The second perspective that Scout primarily presents metrics from is on the Hint degree. For instance, throughout this explicit net request that someone made, how lengthy did it take to finish, and which ranges of the request consumed probably the most time and many others. Wanting on the hint of the replace motion of the UserController under, we will see that on this case 98% of time was spent within the SQL layer, and most of this time was spent in these 2 calls to the question on the highest line. If we click on that SQL button we will see a backtrace and see if we will maybe enhance the question.

These pages are the place you’ll spend most of your time in Scout, and so they provide the type of visibility that’s important when attempting to grasp your efficiency points. You’ll be able to attain Endpoint and Hint pages both by coming immediately from the primary overview web page and insights tabs, or by clicking on the Net Endpoints hyperlink on the prime of the web page (proven under).

Past the fundamentals

Now that we’ve lined the fundamentals of Scout and proven you the primary areas of the system that you’d sometimes use day in, day trip, let’s now change our consideration to a number of the extra superior options which put Scout forward of the group within the APM house.

Error Monitoring

Whether or not you might be utilizing Sentry, Honeybadger, Bugsnag, or Rollbar to your error monitoring, then we have now you lined! Scout integrates seamlessly with these common providers, permitting you to have all of your monitoring in a single place, on the primary overview web page.

The setup course of is comparable no matter which of those providers you utilize, and all it includes is including the API token on the settings display screen of Scout.

Customized Context and Hint Explorer

Why does this efficiency difficulty solely occur at 2:00AM on Tuesday evening from a Brazlian IP tackle? These sorts of inauspicious (however widespread) efficiency points might be tackled with one of the crucial highly effective options of Scout: the hint explorer getting used together with consumer outlined customized context.

Used outlined customized context permits you to inform us what it is advisable see. And it’s properly price investing the comparatively small period of time it can take you to arrange to be granted monitoring superpowers! By default the one context fields you will note are URI and Hostname, as you possibly can see under, however these might be personalized to something that you really want.

The hint explorer’s multi-filter charts (proven above) mean you can study endpoints that match standards that you’ve outlined, after which you possibly can see all of the traces that match these filters within the Transaction Traces a part of the display screen. For instance, maybe you need to see the online requests of a sure consumer, or of all customers on a sure plan dimension, or from a sure a part of the world. These types of operations are straightforward to do within the hint explorer with customized context, and so they provide help to to unravel these hard-to-diagnose, time-consuming efficiency points.

Deploy monitoring

Did this efficiency difficulty that you’re seeing all of a sudden begin occurring after the final deploy? What’s the consumer expertise like throughout the time that you simply deploy? These are the kinds of questions that may be answered with our deploy monitoring characteristic, which is able to place a rocket image on the primary overview chart to point when a deployment occurred.

Deploy monitoring additionally permits you to see particulars comparable to what number of commits had been concerned within the deploy and which department the commits got here from. We are able to glean all this info while you add the SHA or your deployment to the SCOUT_REVISON_SHA environmental variable.

Alerting

Like all good monitoring options, Scout offers you with a classy alerting system which might be configured to ship sure individuals alerts when endpoint response instances or reminiscence utilization metrics go over a sure threshold. These alerts will seem as warning symbols on the primary overview chart, and notifications might be despatched out.

By default, the alerting system will ship notifications to customers in notification teams by way of e-mail, however it will also be configured to work with third occasion providers comparable to Slack, VictorOps, PagerDuty and many others. with our webhook characteristic.

Customized Instrumentation

Are you utilizing libraries exterior of Laravel that we don’t presently instrument? In that case, then initially let our assist staff know and we’ll try to get assist added for you. And within the meantime you possibly can add some customized instrumentation your self, it’s very easy to get began, and it’ll guarantee that you’ve full visibility of your entire utility.

What’s subsequent?

As you possibly can see Scout APM brings a really mature APM monitoring answer to the PHP and Laravel communities. Our clutter-free UI and deep instrumentation provide help to get proper to the center of your efficiency points rapidly, while remaining inexpensive on account of our versatile transaction-based pricing construction.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments