Skip to main content
Laravel Applications

How to Integrate Laravel Nightwatch and Monitor Your App Like a Pro (Step-by-Step Guide)

How to Integrate Laravel Nightwatch and Monitor Your App Like a Pro (Step-by-Step Guide) 1. Introduction In the modern Laravel development workflow, m...

Engr Mejba Ahmed
Author
Engr Mejba Ahmed
Published
Jun 20, 2025
Reading time
3 min · 447 words
How to Integrate Laravel Nightwatch and Monitor Your App Like a Pro (Step-by-Step Guide)
Featured image for How to Integrate Laravel Nightwatch and Monitor Your App Like a Pro (Step-by-Step Guide)

How to Integrate Laravel Nightwatch and Monitor Your App Like a Pro (Step-by-Step Guide)

1. Introduction

In the modern Laravel development workflow, monitoring and observability are essential for ensuring smooth user experiences and catching issues early. Laravel Nightwatch is a new, official monitoring tool built specifically for Laravel applications. It provides deep visibility into your app's performance, errors, requests, jobs, and more—all from a beautiful, developer-first dashboard.

In this guide, you'll learn how to integrate Laravel Nightwatch into your Laravel application, step by step. Whether you're building a solo project or managing production-grade infrastructure, Nightwatch will help you monitor like a pro.


2. What is Laravel Nightwatch?

Laravel Nightwatch is an official SaaS tool from the Laravel ecosystem designed to help you monitor application-level metrics in real-time. It provides:

  • Exception tracking (handled & unhandled)
  • Request performance stats
  • Queue job metrics
  • Real-time user activity
  • Seamless Laravel integration

Think of it as Forge + Telescope + Sentry rolled into one, but purpose-built for Laravel.


3. Prerequisites

Before you begin, ensure the following:

Requirements

Important: Laravel Nightwatch is not compatible with shared hosting environments like Hostinger. You should use a local environment or a VPS (e.g., Laravel Forge, DigitalOcean, etc.).


4. Integration Steps

Step 1: Install Laravel Nightwatch

Run the following from your project root:

composer require laravel/nightwatch

If your Composer version is outdated (e.g., v1.x), upgrade it first:

composer self-update --2

Step 2: Add the Token to .env

After creating a new app in the Nightwatch dashboard, you'll receive a token:

NIGHTWATCH_TOKEN=your-nightwatch-token-here
LOG_CHANNEL=nightwatch

Step 3: Start the Agent

To start sending data:

php artisan nightwatch:agent

You should see:

[INFO] Nightwatch agent initiated: Listening on 127.0.0.1:2407
[INFO] Ingest successful

Step 4: Trigger Activity

Visit routes, trigger exceptions, or queue jobs to see real-time data appear in the dashboard.


5. Monitoring Best Practices

  • Run Agent in Background: Use Supervisor or systemd to keep the agent running in production.
  • Use stack Log Channel: To log to both Nightwatch and default Laravel logs:
LOG_CHANNEL=stack

Update config/logging.php:

'channels' => [
  'stack' => [
    'driver' => 'stack',
    'channels' => ['daily', 'nightwatch'],
  ],
  'nightwatch' => [
    'driver' => 'monolog',
    'handler' => \Laravel\Nightwatch\Log\NightwatchHandler::class,
  ],
],

6. Pro Tips

  • ✅ Use Laravel Forge or a VPS to run Nightwatch agent persistently
  • 🔄 Automate test/agent start via deployment hooks
  • 🧪 Combine with Laravel's feature tests for full-stack observability
  • 🔐 Never commit .env with token to public repos

7. Conclusion

Laravel Nightwatch brings powerful, first-class observability directly to your Laravel projects. With minimal setup, you gain visibility into the health of your application—without needing third-party error tracking or logging systems.

Start monitoring like a pro today. Your future debugging self will thank you.

Engr Mejba Ahmed

About the author

Engr Mejba Ahmed

I'm Engr. Mejba Ahmed, a Software Engineer, Cybersecurity Engineer, and Cloud DevOps Engineer specializing in Laravel, Python, WordPress, cybersecurity, and cloud infrastructure. Passionate about innovation, AI, and automation.

Tags

Keep reading

Browse the blog →