Skip to main content
← All use cases

Monitoring Prometheus Metrics in Laravel Production

You set up Prometheus to collect metrics from your Laravel application. Grafana dashboards show request rates, memory usage, and response times. The team feels good about observability. Then a scheduled report stops generating at 3 AM, a queue worker silently dies, and nobody notices until a customer complains about missing data the next morning.

Prometheus is excellent at collecting numeric time-series data from applications that actively expose metrics. But cron jobs, scheduled tasks, and queue workers are not HTTP endpoints. They run in separate processes, on separate timelines, and most of them never expose a /metrics endpoint at all. A Prometheus scrape only catches what a process publishes during its brief execution window. If a cron job runs for two seconds every six hours, you need the scrape to land in that exact two-second window to see anything. Miss it, and Prometheus has no data point to report.

How Prometheus and Laravel actually work together

The standard setup uses promphp/prometheus_client_php or a similar library to push metrics into Redis, then a Prometheus server scrapes those metrics via a /metrics endpoint exposed by your Laravel app or a sidecar. Common metrics include request duration, queue depth, active job count, and custom business counters.

Metric values persist between scrapes. A counter a job increments at 03:00 is still in Redis at the next scrape, so Prometheus does not need to catch the job while it runs. The gap is different: Prometheus only reports what your code remembered to write. A job that never ran produces no new sample, and a “last successful run” gauge that stops moving looks like any other quiet period until you write an alert rule for it. That rule is time() - last_success_timestamp_seconds > threshold, and it has to exist, with the instrumentation behind it, for every job.

The fundamental mismatch is this: Prometheus assumes the thing it monitors is a long-lived process that exposes its own state. Cron jobs and queue workers start, do their work, and exit. If you forget to instrument one, Prometheus sees nothing.

Where the gaps appear

Scheduled tasks with no metric instrumentation. A cron job runs php artisan send-daily-reports. The command completes successfully, but nobody added a Prometheus counter for it. Prometheus has no visibility. The job could fail silently for days and the dashboards would look normal.

Queue workers that stop without restarting. Horizon manages worker lifecycle, but if Supervisor is not configured or misconfigured, a worker that hits a memory limit simply exits. Prometheus might show “queue depth increasing” if you have that metric, but it will not tell you the worker is gone unless you also track active worker count.

Jobs that exit 0 without doing the work. A “last run” timestamp written when the command finishes proves it finished, not that it processed anything. An import that read zero rows still updates the gauge, and the dashboard stays green.

Grafana dashboards that miss the point. A Grafana panel showing “requests per second” and “CPU usage” tells you the web server is healthy. It tells you nothing about whether the nightly data export completed or whether the queue has jobs stuck for 30 minutes.

Adding Crontinel next to Prometheus

The fix is not to replace Prometheus. It is to add the piece Prometheus cannot do for you: schedule-aware checks on whether each job ran, and whether it did any work.

Step 1: Install the package.

composer require crontinel/laravel
php artisan crontinel:install

Cron run tracking is automatic. The package listens to Laravel’s ScheduledTaskFinished and ScheduledTaskFailed events, so you do not wrap or change your scheduled commands. Connect the app to the hosted dashboard with CRONTINEL_API_KEY in .env.

Step 2: Give each scheduled task a stable name.

// routes/console.php
Schedule::command('reports:send-daily')
    ->dailyAt('06:00')
    ->withoutOverlapping()
    ->onOneServer()
    ->name('send-daily-reports');

The name is what a hosted rule attaches to, so it keeps working if the command string changes. php artisan crontinel:schedule --minimum=1 lists your scheduled tasks and sets up that rule for each one in one pass.

Step 3: Record what the job did.

use Crontinel\Outcome;

Outcome::metric('processed_records', $count);

Zero is a real value. A run that exits 0 with processed_records of 0 fails a rule that requires work, which is the case a “last run” gauge cannot see. The count goes on the run’s receipt and is omitted if you record nothing.

Step 4: Keep Prometheus for the dashboard. Nothing in Prometheus or Grafana changes. If you want a queue or worker number on a Grafana panel, keep exporting it from your own code. Use Crontinel for the alert: did this job run when it was supposed to, and did it do work.

When to rely on Prometheus alone

Prometheus is the right tool for:

The pattern to remember: Prometheus monitors things that are always running. Crontinel monitors things that run on a schedule.

Quick checklist

See also

Start with one HTTP receipt

Five common runtimes post the same outcome body: curl, Node, Python, Sidekiq, and GitHub Actions. Laravel apps can add the Composer package for schedule, queue, and Horizon.

curl -X POST "$CRONTINEL_API_URL/api/v1/ingest/cron" \
  -H "Authorization: Bearer $CRONTINEL_INGEST_KEY" \
  -H "Content-Type: application/json" \
  -d '{"command":"nightly-import","status":"completed","exit_code":0,"outcomes":{"metrics":{"processed_records":0}}}'