Skip to content

Monitoring Tools Setup

Complete guide for Laravel monitoring tools (Telescope, Pulse, and Horizon) in the RawDigs application.

🎯 Overview

RawDigs uses a dedicated MySQL database for monitoring tools to keep monitoring data isolated from application data:

  • Application Data: PostgreSQL (primary database)
  • Monitoring Data: MySQL (separate database for Telescope & Pulse)
  • Queue Processing: Redis (with Horizon monitoring)

🚀 Quick Access

Tool URL Purpose Auth
Horizon http://localhost/monitoring/horizon Queue monitoring & management Auto (local env)
Telescope http://localhost/telescope Debug assistant (requests, queries, jobs) Required
Pulse http://localhost/pulse Real-time performance metrics Required

Laravel Horizon

What is Horizon?

Laravel Horizon provides a beautiful dashboard and code-driven configuration for your Redis queues. It allows you to monitor key metrics like job throughput, runtime, and job failures.

Configuration

Environment Variables:

HORIZON_NAME=RawDigs
HORIZON_DOMAIN=
HORIZON_PATH=monitoring/horizon
HORIZON_PREFIX=

Path: /monitoring/horizon

Features

  • ✅ Real-time queue monitoring
  • ✅ Job metrics and statistics
  • ✅ Failed job management
  • ✅ Worker supervision
  • ✅ Auto-scaling configuration
  • ✅ No authentication required in local environment

Running Horizon

Horizon runs automatically via Docker Compose in a dedicated container:

# Check Horizon status
sail logs horizon -f

# Manually terminate and restart
sail artisan horizon:terminate

# View Horizon configuration
sail artisan horizon:status

Queue & Session Configuration

Redis Database Separation: - DB 0: Default/General - DB 1: Cache - DB 2: Sessions (Cache Layer) - DB 3: Queues ← Horizon monitors this

Session Storage: - Primary Storage: PostgreSQL sessions table (source of truth) - Cache Layer: Redis DB 2 (for fast access) - Fallback: Automatic fallback to database if Redis unavailable

# Sessions - Database with Redis cache
SESSION_DRIVER=database
SESSION_CONNECTION=pgsql
SESSION_TABLE=sessions
SESSION_STORE=redis

# Queue Configuration
QUEUE_CONNECTION=redis
REDIS_QUEUE_DB=3
REDIS_QUEUE=default

Laravel Telescope

What is Telescope?

Telescope provides insight into the requests, exceptions, database queries, queued jobs, mail, notifications, cache operations, scheduled tasks, and more happening in your application.

Configuration

Database: MySQL (monitoring database)

TELESCOPE_ENABLED=true
TELESCOPE_PATH=telescope
TELESCOPE_DB_CONNECTION=mysql_monitoring

Watchers Enabled: - ✅ Batch operations - ✅ Cache interactions - ✅ Commands - ✅ Database queries - ✅ Events - ✅ Exceptions - ✅ Jobs - ✅ Logs - ✅ Mail - ✅ Models - ✅ Notifications - ✅ Redis operations - ✅ Requests/Responses - ✅ Scheduled tasks - ✅ Views

Database Tables

Telescope stores data in MySQL monitoring database: - telescope_entries - telescope_entries_tags - telescope_monitoring

Usage

# Clear all Telescope data
sail artisan telescope:clear

# Prune old records (older than 24 hours)
sail artisan telescope:prune

# Prune with custom hours
sail artisan telescope:prune --hours=48

Laravel Pulse

What is Pulse?

Pulse provides real-time insight into your application's performance and usage. It tracks application metrics like slow requests, jobs, exceptions, queues, and more.

Configuration

Database: MySQL (monitoring database)

PULSE_ENABLED=true
PULSE_PATH=pulse
PULSE_DB_CONNECTION=mysql_monitoring
PULSE_STORAGE_DRIVER=database

Enabled Recorders: - ✅ Cache interactions - ✅ Exceptions (with location) - ✅ Queue statistics - ✅ Slow jobs (>1000ms threshold) - ✅ Slow outgoing requests (>1000ms) - ✅ Slow queries (>1000ms with location) - ✅ Slow requests (>1000ms) - ✅ User jobs - ✅ User requests

Database Tables

Pulse stores data in MySQL monitoring database: - pulse_aggregates - pulse_entries - pulse_values

Usage

# Start Pulse recording (runs automatically)
sail artisan pulse:check

# Clear all Pulse data
sail artisan pulse:clear

# View Pulse statistics
sail artisan pulse:work

🗄️ Database Architecture

MySQL Monitoring Database

Connection Name: mysql_monitoring

DB_MONITORING_HOST=mysql_monitoring
DB_MONITORING_PORT=3306
DB_MONITORING_DATABASE=monitoring
DB_MONITORING_USERNAME=monitoring
DB_MONITORING_PASSWORD=your_password

Exposed Port: 3307 (to avoid conflicts with local MySQL)

Why Separate Databases?

  1. Performance Isolation: Monitoring queries don't impact application performance
  2. Data Separation: Easy to exclude monitoring data from backups
  3. Scaling: Can scale monitoring database independently
  4. Cleanup: Simple to clear all monitoring data without affecting app data

🔧 Migrations

Running Monitoring Migrations

# Run monitoring migrations (Telescope + Pulse)
sail artisan migrate:monitoring

# Fresh migration (drops all tables first)
sail artisan migrate:monitoring --fresh

# Run all migrations (app + monitoring)
sail artisan migrate:all

Migration Locations

  • App Migrations: database/migrations/ → PostgreSQL
  • Monitoring Migrations: database/migrations-monitoring/ → MySQL

🛠️ Troubleshooting

Horizon Not Accessible

  1. Check path configuration:

    HORIZON_PATH=monitoring/horizon
    

  2. Clear configuration cache:

    sail artisan config:clear
    sail artisan config:cache
    

  3. Restart Horizon container:

    docker restart rawdigs-core-app-horizon-1
    

Telescope/Pulse Database Errors

  1. Verify monitoring database connection:

    sail artisan db:show mysql_monitoring
    

  2. Run monitoring migrations:

    sail artisan migrate:monitoring
    

  3. Check connection in Telescope/Pulse:

  4. Telescope: Look for "Connection: mysql_monitoring" in footer
  5. Pulse: Check dashboard loads without errors

If you see "The cookie name cannot be empty":

SESSION_COOKIE=rawdigs_session

Then clear cache:

sail artisan config:clear

📝 Best Practices

Local Development

  1. Enable All Watchers: Keep all Telescope watchers enabled for debugging
  2. Regular Cleanup: Clear old Telescope data periodically
  3. Monitor Queue Jobs: Use Horizon to track background job processing
  4. Check Performance: Use Pulse to identify slow queries and requests

Production Considerations

  1. Disable Telescope: Set TELESCOPE_ENABLED=false in production
  2. Limit Pulse Data: Configure PULSE_STORAGE_KEEP to reasonable value
  3. Restrict Access: Configure proper gate authentication:

    // app/Providers/HorizonServiceProvider.php
    protected function gate(): void
    {
        Gate::define('viewHorizon', function ($user) {
            return in_array($user->email, [
                'admin@rawdigs.com',
            ]);
        });
    }
    

  4. Monitor Disk Usage: Monitoring database can grow large

  5. Schedule Cleanup: Add scheduled commands to clean old data:
    // app/Console/Kernel.php
    $schedule->command('telescope:prune --hours=48')->daily();
    $schedule->command('pulse:clear')->weekly();
    

📚 Official Documentation