jonnx/laravel-timeseries-metrics

轻松从数据库查询中创建指标的时间序列

1.2.0 2018-01-27 00:38 UTC

This package is auto-updated.

Last update: 2024-08-29 04:48:43 UTC


README

一个简单的包,用于生成每日的时间戳基础表,以简化创建和维护时间序列指标和随时间使用的图表。基础表应自动维护,这正是此包的全部目的。生成的表将如下所示

mysql> select * from metric_intervals;
+----+---------------------+---------------------+---------------------+
| id | timestamp           | created_at          | updated_at          |
+----+---------------------+---------------------+---------------------+
|  1 | 2018-01-29 00:00:00 | 2018-01-29 15:44:33 | 2018-01-29 15:44:33 |
|  2 | 2018-01-28 00:00:00 | 2018-01-29 15:44:33 | 2018-01-29 15:44:33 |
|  3 | 2018-01-27 00:00:00 | 2018-01-29 15:44:33 | 2018-01-29 15:44:33 |
|  4 | 2018-01-26 00:00:00 | 2018-01-29 15:44:33 | 2018-01-29 15:44:33 |
|  5 | 2018-01-25 00:00:00 | 2018-01-29 15:44:33 | 2018-01-29 15:44:33 |
|  6 | 2018-01-24 00:00:00 | 2018-01-29 15:44:33 | 2018-01-29 15:44:33 |
|  7 | 2018-01-23 00:00:00 | 2018-01-29 15:44:33 | 2018-01-29 15:44:33 |
|  8 | 2018-01-22 00:00:00 | 2018-01-29 15:44:33 | 2018-01-29 15:44:33 |
+----+---------------------+---------------------+---------------------+
8 rows in set (0.00 sec)

入门

添加仓库

jonnx/laravel-timeseries-metrics

/config/app.php 中添加服务提供者

/*
 * Package Service Providers...
 */
Jonnx\LaravelTimeseriesMetrics\LaravelTimeseriesMetricsServiceProvider::class,

发布 Laravel Timeseries Metrics 的供应商文件

php artisan vendor:publish --provider Jonnx\LaravelTimeseriesMetrics\LaravelTimeseriesMetricsServiceProvider

运行迁移

php artisan migrate

更新回填配置 config/metrics.php

将 interval_backfill 配置更改为您需要回溯的日期。这取决于您启动项目的时间和数据可以追溯多远。

<?php

return [

	/**
	 * the timestamp before which no metric_interval records will be created for
	 * this is used as a backstop when running the initial metrics:createInterval
	 */
	'interval_backfill' => '2018-01-01 00:00:00',
	
];

调度命令 php artisan metrics:createInterval

第一次运行此命令时,将生成完整的回填记录,如果通过调度程序调用,将根据需要生成额外的记录(例如,当过去一天时)。要自动执行此操作,请将以下内容添加到您的 app/Console/Kernel.php

$schedule->command('metrics:createInterval')->daily();

贡献

感谢您考虑为此包做出贡献!由于此包与 Laravel 一起使用,请遵循以下指南:https://laravel.net.cn/docs/5.5/contributions

安全漏洞

如果您在此包中发现安全漏洞,请联系 Jonas Weigert。所有安全漏洞都将得到及时处理。

许可

Laravel Timeseries Metrics 包采用 MIT 许可证授权。