mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-08-30 12:45:32 +08:00
33 lines
1.9 KiB
PHP
33 lines
1.9 KiB
PHP
<?php
|
|
|
|
use think\migration\Migrator;
|
|
|
|
/**
|
|
* nginx 日志分析 - 按小时聚合统计表
|
|
*
|
|
* 每个统计日 + 小时一行,记录 PV/UV/状态码分组/平均耗时。
|
|
* UNIQUE(stat_date, stat_hour) 保证幂等聚合。
|
|
*/
|
|
class NginxStatHour extends Migrator
|
|
{
|
|
public function change()
|
|
{
|
|
$table = $this->table('nginx_stat_hour')
|
|
->setComment('nginx 按小时聚合统计')
|
|
->addColumn('stat_date', 'integer', ['limit' => 11, 'null' => false, 'comment' => '统计日期(YYYYMMDD)', 'signed' => false])
|
|
->addColumn('stat_hour', 'tinyinteger', ['default' => 0, 'comment' => '小时(0-23)', 'signed' => false])
|
|
->addColumn('pv', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '页面浏览量'])
|
|
->addColumn('uv', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '独立访客数'])
|
|
->addColumn('total_bytes', 'biginteger', ['default' => 0, 'comment' => '总流量(字节)'])
|
|
->addColumn('status_2xx', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '2xx 响应数'])
|
|
->addColumn('status_3xx', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '3xx 响应数'])
|
|
->addColumn('status_4xx', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '4xx 响应数'])
|
|
->addColumn('status_5xx', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '5xx 响应数'])
|
|
->addColumn('status_other', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '其他状态码响应数'])
|
|
->addColumn('avg_request_time', 'decimal', ['precision' => 10, 'scale' => 3, 'default' => 0, 'comment' => '平均请求耗时(秒)'])
|
|
->addIndex(['stat_date', 'stat_hour'], ['unique' => true, 'name' => 'uniq_date_hour'])
|
|
->addIndex(['stat_date'], ['name' => 'idx_stat_date'])
|
|
->create();
|
|
}
|
|
}
|