Table of Contents
Setup
Where to start?
Main Overview Page
Insights Tab
Endpoints and Tracing
More than That
Error Monitoring
Custom Context and Trace Explorer
Deployment Tracking
Alerts
Custom Instruments
What’s next?
Home PHP Framework Laravel How to monitor Laravel program using Scout APM?

How to monitor Laravel program using Scout APM?

Nov 07, 2022 pm 08:24 PM
php laravel

How to monitor Laravel program using Scout APM?

Scout APM is a Laravel application performance monitoring tool that ties performance exceptions directly to endpoints, saving developers hours of time spent troubleshooting and debugging.

Scout recently expanded its service offerings to include microservices and managed service monitoring for PHP applications, giving you more cohesive and actionable observability metrics. Learn more about how to monitor Laravel applications with Scout APM by reading the following.

Setup

To start monitoring your Laravel application, you first need a Scout account. If you haven't already, you can Sign up for a 14-day free trial here (no credit card required).

The next thing to do is to add the low-overhead monitoring agent to the project's dependencies, this can be done by using a command in the shell:

composer require scoutapp/scout-apm-laravel
Copy after login

This command will install both Packages: scout-apm-laravel and scout-apm-php. The next step is to define some configuration to link the proxy to your account. To do this, open your project's .env file in your text editor and add the following three lines of configuration to the file:

SCOUT_MONITOR=true
SCOUT_KEY=”enter your Agent Key here”
SCOUT_NAME=”enter the name of you application here”
Copy after login

You can do this in Scout's Find your account's proxy key on the Settings page. Deploy and in about 5 minutes your data will start appearing in Scout. For more information about installing Heroku or troubleshooting installation issues, check out the documentation or email support@scoutapm.com and we'll be happy to help.

Where to start?

Now you've created a Scout account and connected the monitoring agent, but where do you start diagnosing performance issues with your application? Let’s take a look at Scout’s key features that can help you quickly understand performance issues.

Main Overview Page

When you log into Scout, the first page you see is the overview page (shown below), which gives you a clear, uncluttered application Health and performance snapshots at a glance.

The chart is highly configurable, allowing you to change the time period and switch which metrics you want to view. It also features a neat drag-and-drop tool (shown below) that lets you draw a box around the area you'd like to explore in more detail. As you draw these boxes, a popup will dynamically load showing all endpoints visited during this time period. This feature is especially useful when you see a performance spike on a graph and want to understand its cause.

Insights Tab

If you are trying Scout for the first time, a great place to start is with the Insights tab. Here we have a set of algorithms that analyze your project to identify potential n 1 queries and slow queries. These provide you with "low-hanging fruit" performance fixes that can often improve your application's performance immediately.

Endpoints and Tracing

Scout mainly provides two levels of application performance metrics. First, look at it from an endpoint perspective. For example, on average, how long does it take to access this endpoint? Where is the time spent?

If you look at the screenshot below, you can clearly see that out of the 2,371 ms average request time for the 3 visits to this ForgetPasswordController endpoint, 78% was spent at the controller layer, which indicates that this will be The first one investigates if we want to try to improve this slow endpoint.

#The second angle from which Scout primarily displays metrics is at the Trace level. For example, during the time someone made this particular web request, how long it took to complete, and which levels of the request consumed the most time, etc. Looking at the trace of the update operation of the UserController below, we can see that in this case, 98% of the time is spent on the SQL layer, and most of the time is spent on the 2 calls to the first row of the query superior. If we click on that SQL button, we can see a traceback to see if we can improve the query.

These pages are where you spend most of your time in Scout, and they provide you with the visibility that is essential when trying to understand your performance issues. You can access the Endpoint and Trace pages directly from the main overview page and Insights tab, or by clicking the Web Endpoints link at the top of the page (shown below).

More than That

Now that we've covered the basics of Scout and shown you the main areas of the system that you'll typically use day in and day out, let's turn our attention to some more In terms of advanced features, these features make Scout stand out in the APM field.

Error Monitoring

Whether you are using Sentry, Honeybadger, Bugsnag or Rollbar for error monitoring, we have you covered! Scout integrates seamlessly with these popular services, allowing you to monitor all in one place on the main overview page.

No matter which service you use, the setup process is similar, and all that involves is adding the API token on Scout's setup screen .

Custom Context and Trace Explorer

Why does this performance issue only occur from a Brazilian IP address at 2:00 AM on a Tuesday night? These difficult (but common) performance issues can be solved with one of Scout's most powerful features: the Trace Explorer used in conjunction with user-defined custom contexts.

Using a defined custom context allows you to tell us what you need to see. It's worth investing the relatively short setup time to gain monitoring superpowers! By default, the only context fields you will see are the URI and hostname, as shown below, but these can be customized to whatever you want.

Trace Explorer's multi-filter chart (shown above) allows you to check for endpoints that match the criteria you define, and then you can View all traces matching these filters in the Transaction Traces section of the screen. For example, maybe you want to view web requests for a specific user, or for all users of a plan, or from a certain region of the world. These operations are easy to complete in Trace Explorer with custom context, and they can help you gain insight into hard-to-diagnose, time-consuming performance issues.

Deployment Tracking

Do you think this performance issue suddenly started happening after the last deployment? What was the user experience like during your deployment? These are answers that can be answered using the deployment tracking feature, which will place a rocket symbol on the main overview chart to indicate when a deployment occurs.

Deployment tracking also allows you to view details such as the number of commits involved in the deployment and which branch the commits came from. We can collect all of this information when you add SHA or your deployment to the SCOUT_REVISON_SHA environment variable.

Alerts

Like all good monitoring solutions, Scout gives you a sophisticated alerting system that can be configured to alert you when endpoint response time or memory usage metrics exceed a certain threshold. Send alerts to certain people. These alerts will be displayed as a warning symbol on the main overview map and a notification will be issued.

By default, system alerts will send notifications via email to users in the notification group, but they can also be configured with Slack, VictorOps, PagerDuty via our webhook feature Wait for third-party services to work together.

Custom Instruments

Are you using a library outside of Laravel that we don't currently detect? If so, then first let our support team know and we will try to add support for you. In the meantime, you can add some custom tools yourself, it's very easy to get started and it will ensure you have full visibility into the entire application.

What’s next?

As you can see, Scout APM brings a very mature APM monitoring solution to the PHP and Laravel communities. Our clean UI and in-depth tools help you get to the heart of your problem quickly, while remaining affordable thanks to a flexible transaction-based pricing structure.

Original address: https://laravel-news.com/scout-apm-for-monitoring-a-laravel-application

Translation address: https://learnku. com/laravel/t/68744

[Related recommendations: laravel video tutorial]

The above is the detailed content of How to monitor Laravel program using Scout APM?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1669
14
PHP Tutorial
1273
29
C# Tutorial
1256
24
Laravel vs. Python (with Frameworks): A Comparative Analysis Laravel vs. Python (with Frameworks): A Comparative Analysis Apr 21, 2025 am 12:15 AM

Laravel is suitable for projects that teams are familiar with PHP and require rich features, while Python frameworks depend on project requirements. 1.Laravel provides elegant syntax and rich features, suitable for projects that require rapid development and flexibility. 2. Django is suitable for complex applications because of its "battery inclusion" concept. 3.Flask is suitable for fast prototypes and small projects, providing great flexibility.

The Compatibility of IIS and PHP: A Deep Dive The Compatibility of IIS and PHP: A Deep Dive Apr 22, 2025 am 12:01 AM

IIS and PHP are compatible and are implemented through FastCGI. 1.IIS forwards the .php file request to the FastCGI module through the configuration file. 2. The FastCGI module starts the PHP process to process requests to improve performance and stability. 3. In actual applications, you need to pay attention to configuration details, error debugging and performance optimization.

What happens if session_start() is called multiple times? What happens if session_start() is called multiple times? Apr 25, 2025 am 12:06 AM

Multiple calls to session_start() will result in warning messages and possible data overwrites. 1) PHP will issue a warning, prompting that the session has been started. 2) It may cause unexpected overwriting of session data. 3) Use session_status() to check the session status to avoid repeated calls.

Composer: Aiding PHP Development Through AI Composer: Aiding PHP Development Through AI Apr 29, 2025 am 12:27 AM

AI can help optimize the use of Composer. Specific methods include: 1. Dependency management optimization: AI analyzes dependencies, recommends the best version combination, and reduces conflicts. 2. Automated code generation: AI generates composer.json files that conform to best practices. 3. Improve code quality: AI detects potential problems, provides optimization suggestions, and improves code quality. These methods are implemented through machine learning and natural language processing technologies to help developers improve efficiency and code quality.

Frontend with Laravel: Exploring the Possibilities Frontend with Laravel: Exploring the Possibilities Apr 20, 2025 am 12:19 AM

Laravel can be used for front-end development. 1) Use the Blade template engine to generate HTML. 2) Integrate Vite to manage front-end resources. 3) Build SPA, PWA or static website. 4) Combine routing, middleware and EloquentORM to create a complete web application.

What is the significance of the session_start() function? What is the significance of the session_start() function? May 03, 2025 am 12:18 AM

session_start()iscrucialinPHPformanagingusersessions.1)Itinitiatesanewsessionifnoneexists,2)resumesanexistingsession,and3)setsasessioncookieforcontinuityacrossrequests,enablingapplicationslikeuserauthenticationandpersonalizedcontent.

What database versions are compatible with the latest Laravel? What database versions are compatible with the latest Laravel? Apr 25, 2025 am 12:25 AM

The latest version of Laravel10 is compatible with MySQL 5.7 and above, PostgreSQL 9.6 and above, SQLite 3.8.8 and above, SQLServer 2017 and above. These versions are chosen because they support Laravel's ORM features, such as the JSON data type of MySQL5.7, which improves query and storage efficiency.

What is the difference between php framework laravel and yii What is the difference between php framework laravel and yii Apr 30, 2025 pm 02:24 PM

The main differences between Laravel and Yii are design concepts, functional characteristics and usage scenarios. 1.Laravel focuses on the simplicity and pleasure of development, and provides rich functions such as EloquentORM and Artisan tools, suitable for rapid development and beginners. 2.Yii emphasizes performance and efficiency, is suitable for high-load applications, and provides efficient ActiveRecord and cache systems, but has a steep learning curve.

See all articles