Laravel performance monitoring in Honeybadger

Published on by

Laravel performance monitoring in Honeybadger image

Great news, Laravel friends! You can now monitor the performance of your Laravel apps with Honeybadger.

Yes, you read that right: Laravel performance monitoring in Honeybadger! Many of you have asked for this, and we're excited to tell you about it.

Earlier this year, we launched Honeybadger Insights, a new logging and performance monitoring tool bundled with Honeybadger. Insights allows you to query your logs and events to diagnose performance issues, perform root-cause analyses, and create charts and dashboards to see what's happening in real time. It also works automatically with Honeybadger’s best-in-class error tracking, unlocking direct access to query and analyze your error data.

Today, we’re turning Insights up a notch with two new features just for Laravel developers:

  1. A new Laravel performance dashboard. Instead of creating a dashboard from scratch, select “ Laravel” from our list of curated monitoring dashboards. The new dashboard allows you to monitor requests and background jobs, slow requests and queries, and more.
  2. Laravel performance instrumentation. Our composer package now automatically sends performance events and metrics from Laravel. The new instrumentation is what powers your dashboard, but you can also use our query language—BadgerQL—to dig into the data yourself.

The Laravel Performance Dashboard

When creating a dashboard in Honeybadger, you have several options. To get started, select the new “ Laravel” dashboard from the list:

Our team curates each dashboard to make it easy for you to ramp up with Honeybadger and BadgerQL. Install a monitoring integration (such as our composer package), select the matching dashboard, and you're done.

We recently deployed a production Laravel app at Honeybadger (Statamic, it’s fantastic!). Here’s what our dashboard looks like:

Honeybadger’s new Laravel Performance Dashboard

The new Laravel dashboard includes the following widgets by default:

  • Request counts — A line chart of the number of requests to your Laravel app over time. Know immediately when you have a spike and when traffic is steady.
  • Response distributions — A bar chart that shows the response distributions binned by 100ms. See how a majority of your requests are performing.
  • Job durations — A line chart showing the average duration for each of your Laravel jobs. Helps you keep the processing pipeline optimized.
  • Responses — A line chart showing the number of responses grouped by status code. Are you having a spike in 403 Forbidden responses? This chart will tell you about it.
  • Slowest controllers — Your slowest Laravel controllers, with Apdex scores based on 200ms response times. This table tells you where you can improve performance.
  • Slowest 10 requests — Your slowest requests by controller and duration. Use the included Request ID to query for events that happened during that request (such as a slow SQL query, N+1 queries, etc.).
  • Slowest queries per request — Quickly see your slowest queries, including the average & max duration per Request ID.
  • Slowest 10 outgoing requests — Your slowest outgoing requests, like when you call an external REST API.
  • Slowest 10 queries — Your slowest SQL queries overall.

After you create a dashboard, you don't have to keep the default widgets—we designed Honeybadger dashboards to be customized. In fact, reading the underlying queries is a great way to learn BadgerQL. To see the query and raw data behind any dashboard widget, click "Open in Query Editor":

You can tweak the query, review the results, and update the dashboard from there:

Laravel performance instrumentation

The data that feeds the new Laravel Dashboard is sent automatically from the honeybadger-laravel composer package starting in version 4.2.x—so make sure you upgrade to the latest version. After you upgrade, you'll also need to enable the Honeybadger Insights instrumentation for Laravel by adding the following to your config/honeybadger.php config file:

'events' => [
'enabled' => true
]

We'll enable this feature by default in a future package version, but you must opt in for now. After deploying the new Laravel config, some new events and metrics will begin to appear in Honeybadger Insights, and your Laravel dashboard will come alive!

We also added some new configuration and documentation to help you customize the events you care about. To learn more, check out our new Sending Events to Insights guide.

Sending custom events

You can also send your own Laravel events to Honeybadger using the Honeybadger.event method:

Honeybadger.event('user_activity', [
'action' => 'registration',
'user_id' => 123
])

The first argument is the type of the event (event_type), and the second argument is an object containing any additional data you want to include.

You can find these events with the following BadgerQL query:

fields @ts, @preview
| filter event_type::str == "user_activity"
| filter action::str == "registration"
| sort @ts

Sending your Laravel application logs

Honeybadger’s approach to logging is “Log everything, ask anything.” You don’t always know what information will be helpful when you’re troubleshooting an outage (or an error). In addition to the performance telemetry that we now record by default, you can send your Laravel application logs to Honeybadger.

There are several ways to do this:

  1. Send your logs from your infrastructure (i.e., your server, Docker containers, etc.)
  2. Use our Monolog handler
  3. Use our Laravel channel driver

Using our channel driver is the simplest way to get started in Laravel. To configure it, add our event driver to your config/logging.php config file:

'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => ['single', 'honeybadger'],
'ignore_exceptions' => false,
],
'honeybadger' => [
'driver' => 'custom',
'via' => Honeybadger\HoneybadgerLaravel\HoneybadgerLogEventDriver::class,
'name' => 'honeybadger',
'level' => 'info',
],
],

Now you can write log messages as usual with Laravel's log facade, and they'll show up in Honeybadger:

Log::info('An info message');
Log::error('An error message with context', ["some-key" => "some-value"]);

And, of course, this also works for Lumen!

Laravel performance monitoring in Honeybadger

To try out the new Laravel performance monitoring features in Honeybadger, all you need to do is sign up for a free Honeybadger account. We include 50MB/day (1.5GB/month) ingest for free, and you can upgrade to a paid plan if you need more. Our pricing is reasonable, too! Honeybadger is almost 8 times cheaper than Papertrail for logging. 🤯

Whew! That was a lot to get through, and we’re just scratching the surface of our roadmap for performance monitoring in Laravel. Questions or comments? Schedule a call with us to learn how Honeybadger can help streamline your monitoring stack and your costs.

Joshua Wood photo

Joshua Wood is a software developer and the co-founder of Honeybadger.io — the full-stack web application monitoring tool for developers.

Filed in:
Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

Laravel Forge logo

Laravel Forge

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Forge
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
No Compromises logo

No Compromises

Joel and Aaron, the two seasoned devs from the No Compromises podcast, are now available to hire for your Laravel project. ⬧ Flat rate of $7500/mo. ⬧ No lengthy sales process. ⬧ No contracts. ⬧ 100% money back guarantee.

No Compromises
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Bacancy logo

Bacancy

Supercharge your project with a seasoned Laravel developer with 4-6 years of experience for just $2500/month. Get 160 hours of dedicated expertise & a risk-free 15-day trial. Schedule a call now!

Bacancy
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
Lunar: Laravel E-Commerce logo

Lunar: Laravel E-Commerce

E-Commerce for Laravel. An open-source package that brings the power of modern headless e-commerce functionality to Laravel.

Lunar: Laravel E-Commerce
LaraJobs logo

LaraJobs

The official Laravel job board

LaraJobs
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit
Supercharge Your SaaS Development with FilamentFlow: The Ultimate Laravel Filament Boilerplate logo

Supercharge Your SaaS Development with FilamentFlow: The Ultimate Laravel Filament Boilerplate

Build your SaaS application in hours. Out-of-the-box multi-tenancy and seamless Stripe integration. Supports subscriptions and one-time purchases, allowing you to focus on building and creating without repetitive setup tasks.

Supercharge Your SaaS Development with FilamentFlow: The Ultimate Laravel Filament Boilerplate
Rector logo

Rector

Your partner for seamless Laravel upgrades, cutting costs, and accelerating innovation for successful companies

Rector
MongoDB logo

MongoDB

Enhance your PHP applications with the powerful integration of MongoDB and Laravel, empowering developers to build applications with ease and efficiency. Support transactional, search, analytics and mobile use cases while using the familiar Eloquent APIs. Discover how MongoDB's flexible, modern database can transform your Laravel applications.

MongoDB

The latest

View all →
Asymmetric Property Visibility in PHP 8.4 image

Asymmetric Property Visibility in PHP 8.4

Read article
Access Laravel Pulse Data as a JSON API image

Access Laravel Pulse Data as a JSON API

Read article
Laravel Forge adds Statamic Integration image

Laravel Forge adds Statamic Integration

Read article
Transform Data into Type-safe DTOs with this PHP Package image

Transform Data into Type-safe DTOs with this PHP Package

Read article
PHPxWorld - The resurgence of PHP meet-ups with Chris Morrell image

PHPxWorld - The resurgence of PHP meet-ups with Chris Morrell

Read article
Herd Executable Support and Pest 3 Mutation Testing in PhpStorm 2024.3 image

Herd Executable Support and Pest 3 Mutation Testing in PhpStorm 2024.3

Read article