renoki-co / octane-exporter
使用此 Prometheus 导出器导出 Laravel Octane 指标。
1.1.0
2022-07-16 21:28 UTC
Requires
- laravel/framework: ^8.81|^9.7.0
- laravel/octane: ^1.2.5
- renoki-co/laravel-exporter-contracts: ^1.4|^2.1.1
Requires (Dev)
- mockery/mockery: ^1.5
- orchestra/testbench: ^6.28|^7.0
- orchestra/testbench-core: ^6.28|^7.0
- phpunit/phpunit: ^9.5.13
This package is auto-updated.
Last update: 2024-09-11 16:47:21 UTC
README
使用此 Prometheus 导出器导出 Laravel Octane 指标。
🤝 支持
如果你在您的生产应用、演示、业余项目、学校项目等中使用一个或多个 Renoki Co. 的开源包,请通过 Github Sponsors 支持我们的工作。 📦
🚀 安装
您可以通过 composer 安装此包
composer require renoki-co/octane-exporter
如果您尚未发布您的 Octane 设置,请这样做
php artisan octane:install
接下来,在您的 config/octane.php
中添加以下 Octane 表。这些表将用于跟踪事件的统计信息
return [ 'tables' => [ 'octane_exporter_requests:1' => [ 'total_count' => 'int', '2xx_count' => 'int', '3xx_count' => 'int', '4xx_count' => 'int', '5xx_count' => 'int', ], 'octane_exporter_tasks:1' => [ 'total_count' => 'int', 'active_count' => 'int', ], 'octane_exporter_workers:1' => [ 'active_count' => 'int', ], 'octane_exporter_ticks:1' => [ 'total_count' => 'int', 'active_count' => 'int', ], // ... ], ];
最后一步是在 config/octane.php
中添加以下监听器,在现有的监听器之后
return [ 'listeners' => [ WorkerStarting::class => [ // ... \RenokiCo\OctaneExporter\Listeners\TrackStartedWorkers::class, ], RequestTerminated::class => [ // ... \RenokiCo\OctaneExporter\Listeners\TrackTerminatedRequests::class, ], TaskReceived::class => [ // ... \RenokiCo\OctaneExporter\Listeners\TrackReceivedTasks::class, ], TaskTerminated::class => [ // ... \RenokiCo\OctaneExporter\Listeners\TrackTerminatedTasks::class, ], TickReceived::class => [ // ... \RenokiCo\OctaneExporter\Listeners\TrackReceivedTicks::class, ], TickTerminated::class => [ // ... \RenokiCo\OctaneExporter\Listeners\TrackTerminatedTicks::class, ], WorkerStopping::class => [ // ... \RenokiCo\OctaneExporter\Listeners\TrackStoppedWorkers::class, ], ], ];
🙌 使用方法
此包非常简单。安装后,它将在 /exporter/group/octane-metrics
上注册路由,您可以将其指向 Prometheus 以进行抓取。
scrape_configs: - job_name: 'octane' metrics_path: '/exporter/group/octane-metrics' scrape_interval: 5 static_configs: - targets: ['localhost:8000'] labels: app: 'my-octane-app'
请注意,指标是按进程计算的。将您的 Prometheus 抓取器指向运行 Octane 启动命令的所有实例。
# HELP laravel_octane_active_tasks_count Get the number of active tasks that pass through Octane.
# TYPE laravel_octane_active_tasks_count gauge
laravel_octane_active_tasks_count{remote_addr="",addr="",name=""} 0
# HELP laravel_octane_active_ticks_count Get the number of active ticks that run currently in Octane.
# TYPE laravel_octane_active_ticks_count gauge
laravel_octane_active_ticks_count{remote_addr="",addr="",name=""} 0
# HELP laravel_octane_active_workers_count Get the number of active workers for Octane.
# TYPE laravel_octane_active_workers_count gauge
laravel_octane_active_workers_count{remote_addr="",addr="",name=""} 8
# HELP laravel_octane_requests_count Get the number of requests, by status, that passed through Octane.
# TYPE laravel_octane_requests_count gauge
laravel_octane_requests_count{remote_addr="",addr="",name="",status="2xx_count"} 7
laravel_octane_requests_count{remote_addr="",addr="",name="",status="3xx_count"} 0
laravel_octane_requests_count{remote_addr="",addr="",name="",status="4xx_count"} 0
laravel_octane_requests_count{remote_addr="",addr="",name="",status="5xx_count"} 0
laravel_octane_requests_count{remote_addr="",addr="",name="",status="total_count"} 7
# HELP laravel_octane_status Check if the octane service is running. 1 = active, 0 = inactive
# TYPE laravel_octane_status gauge
laravel_octane_status{remote_addr="",addr="",name=""} 1
# HELP laravel_octane_total_tasks_count Get the number of total tasks that passed through Octane.
# TYPE laravel_octane_total_tasks_count gauge
laravel_octane_total_tasks_count{remote_addr="",addr="",name=""} 0
# HELP laravel_octane_total_ticks_count Get the number of total ticks that got through Octane. This is the equivalent of seconds passed since this server is alive.
# TYPE laravel_octane_total_ticks_count gauge
laravel_octane_total_ticks_count{remote_addr="",addr="",name=""} 1242
# HELP php_info Information about the PHP environment.
# TYPE php_info gauge
php_info{version="8.0.11"} 1
🐛 测试
vendor/bin/phpunit
🤝 贡献
有关详细信息,请参阅 CONTRIBUTING。
🔒 安全
如果您发现任何与安全相关的问题,请通过电子邮件 alex@renoki.org 联系,而不是使用问题跟踪器。