fidum / laravel-dashboard-vapor-metrics-tile
Vapor 环境缓存和数据库指标瓷砖用于 Laravel Dashboard
4.1.0
2024-03-13 16:52 UTC
Requires
- php: ^8.1
- fidum/laravel-dashboard-chart-tile: ^6.0
- laravel/vapor-cli: ^1.60
- spatie/laravel-dashboard: ^3.0
Requires (Dev)
- mockery/mockery: ^1.5
- orchestra/testbench: ^8.0|^9.0
- phpunit/phpunit: ^10.5
README
显示所有 Laravel Vapor 项目的指标 - 包括缓存、数据库和环境的指标和图表!
安装
您可以通过 composer 安装此包
composer require fidum/laravel-dashboard-vapor-metrics-tile
使用
在 dashboard
配置文件中,必须在 tiles
键中添加此配置。为 caches
、databases
和 environments
提供了单独的设置。
// in config/dashboard.php return [ // ... 'tiles' => [ 'vapor_metrics' => [ 'secret' => env('VAPOR_API_TOKEN'), // optional: Uses `VAPOR_API_TOKEN` env by default 'refresh_interval_in_seconds' => 300, // optional: Default: 300 seconds (5 minutes) 'period' => '7d', // optional: 1m, 5m, 30m, 1h, 8h, 1d (default), 3d, 7d, 1M 'caches' => [ // Leave empty if you don't want any cache tiles 'My Cache Instance' => [ // Key will be used as the title of the displayed tile 'cache_id' => 222, // required: The id of your vapor cache instance 'period' => '7d', // optional: 1m, 5m, 30m, 1h, 8h, 1d (default), 3d, 7d, 1M 'refresh_interval_in_seconds' => 60, // optional: override individual tile 'secret' => null, // :optional: override individual tile ], 'Another Cache' => ['cache_id' => 333] ], 'databases' => [ // Leave empty if you don't want any database tiles 'My Database' => [ // Key will be used as the title of the displayed tile 'database_id' => 555, // required: The id of your vapor database instance 'period' => '7d', // optional: 1m, 5m, 30m, 1h, 8h, 1d (default), 3d, 7d, 1M 'refresh_interval_in_seconds' => 60, // optional: override individual tile 'secret' => null, // :optional: override individual tile ], 'Another Database' => ['database_id' => 444] ], 'environments' => [ // Leave empty if you don't want any envrionment tiles 'My Staging Website' => [ // Key will be used as the title of the displayed tile 'project_id' => 1111, // required: The id of your vapor project 'environment' => 'staging', // optional: Defaults to 'production' 'period' => '7d', // optional: 1m, 5m, 30m, 1h, 8h, 1d (default), 3d, 7d, 1M 'refresh_interval_in_seconds' => 60, // optional: override individual tile 'secret' => null, // :optional: override individual tile ], 'My Production Website' => ['project_id' => 1111], ], ], ], ];
在 app\Console\Kernel.php
中,您应该每 x
分钟运行以下操作。只需添加您在上文中配置的相关瓷砖的命令。
// in app/console/Kernel.php protected function schedule(Schedule $schedule) { $schedule->command(\Fidum\VaporMetricsTile\Commands\FetchVaporCacheMetricsCommand::class)->everyThirtyMinutes(); $schedule->command(\Fidum\VaporMetricsTile\Commands\FetchVaporDatabaseMetricsCommand::class)->everyThirtyMinutes(); $schedule->command(\Fidum\VaporMetricsTile\Commands\FetchVaporEnvironmentMetricsCommand::class)->everyThirtyMinutes(); }
在您的仪表板视图中,您可以使用一个或所有这些组件中的一个或多个。`tileName` 和 `position` 属性是 必需的。`tileName` 属性的值需要与配置中指定的名称匹配
<x-dashboard> <livewire:vapor-environment-metrics-tile tileName="My Production Website" position="a1:a4" /> <livewire:vapor-cache-metrics-tile tileName="My Cache Instance" position="b1:a2" /> <livewire:vapor-database-metrics-tile tileName="My Database" position="b3:b4" /> <livewire:vapor-environment-metrics-chart-tile type="http-requests-avg-duration" tileName="My Production Website" position="a5:a6" /> <livewire:vapor-environment-metrics-chart-tile type="cli-avg-duration" tileName="My Production Website" position="a7:a8" /> <livewire:vapor-environment-metrics-chart-tile type="queue-avg-duration" tileName="My Production Website" position="a9:a10" /> <livewire:vapor-environment-metrics-chart-tile type="http-requests-total" tileName="My Production Website" position="b5:b6" /> <livewire:vapor-environment-metrics-chart-tile type="cli-invocations-total" tileName="My Production Website" position="b7:b8" /> <livewire:vapor-environment-metrics-chart-tile type="queue-invocations-total" tileName="My Production Website" position="b9:b10" /> </x-dashboard>
对于图表,应提供一个额外的 `type` 值以选择要显示的图表
cli-avg-duration
:平均 CLI 调用持续时间(毫秒)cli-invocations-total
:CLI 调用次数http-requests-avg-duration
:平均 HTTP 请求持续时间(毫秒)http-requests-total
:HTTP 请求次数queue-avg-duration
:平均队列调用持续时间(毫秒)queue-invocations-total
:队列调用次数
图表使用 fidum/laravel-dashboard-chart-tile 内部。您可以使用以下附加属性进行进一步自定义
height
设置图表的高度,根据您的仪表板布局,您可能需要调整此值(默认为100%
)。refreshIntervalInSeconds
使用此选项覆盖单个瓷砖的刷新率(默认为上文中配置的设置)
测试
composer test
变更日志
有关最近更改的更多信息,请参阅 CHANGELOG
贡献
有关详细信息,请参阅 CONTRIBUTING
安全性
如果您发现任何安全问题,请通过 :author_email 发送电子邮件,而不是使用问题跟踪器。
鸣谢
许可证
MIT 许可证(MIT)。有关更多信息,请参阅 许可证文件