itsemon245/lamet
High-performance Laravel metrics recorder and aggregator for Grafana dashboards. Install via Artisan, configure DB/cache, track counters, gauges, and timings, flush/clean via commands, and run scheduled tasks to persist aggregates.
events and service container for custom metric sources (e.g., queue jobs, HTTP requests). Supports middleware for automatic metric collection.lamet:clean command).Illuminate\Queue\Events\JobProcessed or Illuminate\Http\Kernel events.lamet.http.duration)..env:
LAMET_CACHE_DRIVER=redis
LAMET_CACHE_TTL=3600
lamet_metrics table if cache fails (risk of data loss if DB is down).lamet:install command.name, labels, value, timestamp). Custom aggregations may require raw SQL or query scopes.http.request.duration).orders.processed, payments.failed) via custom collectors.composer.json constraints).config/cache.php).lamet:clean runs on a separate worker to avoid contention.config/lamet.php for customizations (e.g., default TTLs, metric prefixes).composer require itsemon245/lamet
php artisan lamet:install
app/Console/Kernel.php:
$schedule->command('lamet:clean')->daily();
use Itsemon245\Lamet\Facades\Lamet;
Lamet::middleware(function ($request) {
Lamet::record('http.requests', 1, ['method' => $request->method(), 'path' => $request->path()]);
});
Lamet::gauge('memory.usage', memory_get_usage(true));
Lamet::histogram('db.query.duration', $executionTime);
SELECT timestamp, value, labels
FROM lamet_metrics
WHERE name = 'http.request.duration'
ORDER BY timestamp DESC
LIMIT 1000
LAMET_CACHE_TTL based on retention needs (e.g., 1 hour for real-time, 1 day for aggregates).maxmemory-policy to avoid evictions.lamet:clean regularly (e.g., daily) to purge old metrics. Log cleanup stats for auditing.lamet_metrics for name, timestamp, and labels if querying frequently..env and config/lamet.php in version control. Use Laravel Forge/Envoyer for deployments.php artisan lamet:flush + manual triggers).lamet:clean failures (e.g., DB connection issues).How can I help you explore Laravel packages today?