simbi / laravel-metrics-exporter
Prometheus metrics exporter for Laravel applications following RED/USE methodology
Package info
github.com/simbiosesocial/laravel-metrics-exporter
pkg:composer/simbi/laravel-metrics-exporter
0.1.0
2026-03-07 01:10 UTC
Requires
- php: ^8.2
- laravel/framework: ^10.0|^11.0
- spatie/laravel-prometheus: ^1.0
Requires (Dev)
- orchestra/testbench: ^8.0|^9.0
- phpunit/phpunit: ^10.0|^11.0
README
Prometheus metrics exporter for Laravel applications following RED/USE methodology.
Requirements
- PHP 8.2+
- Laravel 10.x or 11.x
Installation
composer require simbi/laravel-metrics-exporter
The package uses Laravel's auto-discovery, so the service provider will be registered automatically.
Configuration
Publish the configuration file:
php artisan vendor:publish --tag=metrics-exporter-config
Set the application name in your .env:
PROMETHEUS_APP_NAME=my-app-name
Environment Variables
| Variable | Default | Description |
|---|---|---|
METRICS_EXPORTER_ENABLED |
true |
Enable/disable metrics exporter |
PROMETHEUS_APP_NAME |
app |
Application name for the app label |
METRICS_EXPORTER_ENV_VAR |
APP_ENV |
Environment variable for the environment label |
METRICS_EXPORTER_PATH |
metrics |
URL path for the metrics endpoint |
PROMETHEUS_CACHE_STORE |
file |
Cache store for persisting metrics |
Feature Flags
You can enable/disable specific collectors:
// config/metrics-exporter.php 'features' => [ 'http' => true, // HTTP request metrics (RED) 'queue' => true, // Queue job metrics 'process' => true, // Process metrics (USE) ],
Metrics Exposed
HTTP Metrics (RED)
http_requests_total- Counter of total HTTP requestshttp_request_duration_seconds- Histogram of request durationshttp_requests_in_flight- Gauge of current in-flight requests
Queue Metrics
jobs_processed_total- Counter of processed jobsjobs_failed_total- Counter of failed jobsjobs_processing_duration_seconds- Histogram of job processing durations
Process Metrics (USE)
process_cpu_seconds_total- Total CPU timeprocess_resident_memory_bytes- Resident memory sizeprocess_open_fds- Open file descriptorsprocess_start_time_seconds- Process start time
Manual Recording (AMQP/RabbitMQ)
For consumers that don't use Laravel's Queue system:
use Simbi\MetricsExporter\Support\MetricsRecorder; $recorder = app(MetricsRecorder::class); $startTime = microtime(true); try { $this->processMessage($message); $recorder->jobProcessed('emails', 'SendWelcomeEmail', microtime(true) - $startTime); } catch (Throwable $e) { $recorder->jobFailed('emails', 'SendWelcomeEmail'); throw $e; }
Running Tests
Clone the repository and run tests:
Local (requires PHP 8.2+)
git clone git@github.com:simbiosesocial/laravel-metrics-exporter.git cd laravel-metrics-exporter composer install composer test
Using Docker
git clone git@github.com:simbiosesocial/laravel-metrics-exporter.git cd laravel-metrics-exporter # Run tests docker compose run --rm tests # Interactive shell for debugging docker compose run --rm shell # Rebuild after changing dependencies docker compose build --no-cache
Contributing
This is an internal package for Simbi Social applications.
License
Proprietary - Simbi Social