Laravel Telescope: Practical Application Monitoring

3 min readUpdated on

This guide shows how to set up and use Laravel Telescope for application monitoring.

Introduction

Laravel Telescope is an invaluable tool in the process of debugging and monitoring Laravel applications. It facilitates error identification, performance analysis, and system operation control in real-time or from a historical event perspective.

Laravel Telescope is the official debugging tool for the Laravel framework, created by the Laravel team. It enables monitoring of various aspects of application operation, such as SQL queries, HTTP requests, exception handling, queue operations, and many others.

Unlike Laravel Debugbar, which operates in real-time in the browser, Telescope offers a dedicated web interface with operation history, enabling deeper analysis and diagnostics of problems after they occur.

Installation

bash
composer require laravel/telescope --dev
php artisan telescope:install
php artisan migrate

It is recommended to install Telescope as a development dependency (--dev), as it should not be used in production environments due to performance and security concerns. With --dev, remove the TelescopeServiceProvider entry from bootstrap/providers.php after telescope:install, register both Telescope providers in AppServiceProvider::register() only when $this->app->environment('local') and class_exists(\Laravel\Telescope\TelescopeServiceProvider::class), and add laravel/telescope to extra.laravel.dont-discover in composer.json, otherwise production will fail once dev dependencies are not installed.

Without pruning, the telescope_entries table grows quickly. Schedule telescope:prune daily (it removes entries older than 24 hours by default; use --hours=48 to keep more).

Basic Configuration

After installation, the config/telescope.php file contains all Telescope settings:

php
<?php

return [
    'path' => 'telescope',
    'enabled' => env('TELESCOPE_ENABLED', true),
    'storage' => [
        'database' => [
            'connection' => env('DB_CONNECTION', 'mysql'),
            'chunk' => 1000,
        ],
    ],
    'watchers' => [
        // ...
    ],
];

Access Control to Telescope Panel

By default, Telescope is only available in the local environment. To enable access in other environments, modify the gate method in TelescopeServiceProvider.php. Make sure APP_ENV is production in production, otherwise Telescope is publicly available:

php
protected function gate(): void
{
    Gate::define('viewTelescope', function (User $user) {
        return in_array($user->email, [
            '[email protected]',
            '[email protected]'
        ]);
    });
}

Key Features

  1. HTTP Request Monitoring

    • Records all incoming HTTP requests with details:
      • URL, HTTP Method, Parameters, Headers, Response Code, Execution Time
  2. Database Query Monitoring

    • Logs all SQL queries:
      • Full SQL Query, Parameters, Execution Time
    php
    $users = DB::table('users')->where('active', true)->orderBy('created_at', 'desc')->get();
    
  3. Exception Monitoring

    • Automatically saves all exceptions with type, trace, location, context
  4. Cache Operation Monitoring

    • Tracks get/set/forget operations
    php
    Cache::put('user_profile', $userProfile, 3600);
    $profile = Cache::get('user_profile');
    
  5. Queue Job Monitoring

    • Records queued and executed queue jobs
    php
    ProcessPodcast::dispatch($podcast)->onQueue('podcasts');
    
  6. Log Monitoring

    • Log entries at error level and above by default (raise the log watcher's level in config/telescope.php to record info)
    php
    Log::info('User logged in', ['user_id' => $user->id]);
    
  7. Notification Monitoring

    • Tracks notifications with type, channel, status
  8. Event Monitoring

    • Tracks events, payload, and listeners
    php
    event(new UserRegistered($user));
    
  9. Eloquent Model Monitoring

    • Hydration, serialization, collection operations
  10. Artisan Command Monitoring

    • Records all commands, time, options

Security

Conclusion

Laravel Telescope is an essential tool for every Laravel developer, offering:

  • Comprehensive application monitoring
  • Detailed request and query tracking
  • Efficient error debugging

Related articles

Existing system support

Need help with a live application?

I help companies improve live systems, clean up delivery workflows, and ship new features without adding avoidable complexity.

Comments (0)
Sign in to leave a comment

You need to be signed in to add a comment.

Login

Need someone to take responsibility for the next step?

Let’s talk about your project and define a scope that actually makes sense for your goals.