elemenx / laravel-influxdb
一个旨在提供、设置和使用 Laravel 中 influxdb-php 库的服务。
0.0.2
2020-07-21 07:56 UTC
Requires
- php: ^7.1.3
- guzzlehttp/guzzle: ^6.3
- illuminate/support: ^5.5|^6.0|^7.0
- influxdb/influxdb-php: ^1.15
- monolog/monolog: ^1.12|^2.0
Requires (Dev)
- mockery/mockery: ^1.0
- orchestra/testbench: ^3.5|^4.0
- phpunit/phpunit: ^6.0|^7.0|^8.0|^9.0
- squizlabs/php_codesniffer: ^3.5
This package is auto-updated.
Last update: 2024-09-25 15:05:29 UTC
README
一个旨在提供、设置和使用 Laravel 中 influxdb-php 库的服务。
要求
- php >=7.1.3
- Laravel 5.5+
- influxdb-php 1.14+
安装
首先通过 Composer 拉取包。
$ composer require oanhnn/laravel-influxdb
用法
读取数据
<?php // executing a query will yield a resultset object $result = InfluxDB::query('select * from test_metric LIMIT 5'); // get the points from the resultset yields an array $points = $result->getPoints();
写入数据
<?php // create an array of points $points = array( new InfluxDB\Point( 'test_metric', // name of the measurement null, // the measurement value ['host' => 'server01', 'region' => 'us-west'], // optional tags ['cpucount' => 10], // optional additional fields time() // Time precision has to be set to seconds! ), new InfluxDB\Point( 'test_metric', // name of the measurement null, // the measurement value ['host' => 'server01', 'region' => 'us-west'], // optional tags ['cpucount' => 10], // optional additional fields time() // Time precision has to be set to seconds! ) ); $result = InfluxDB::writePoints($points, \InfluxDB\Database::PRECISION_SECONDS);
日志记录
注意 此功能在 Laravel 版本 5.6+ 中可用。
在 config/logging.php
文件中,使用驱动 influxdb
配置你的日志。
<?php return [ // ... 'channels' => [ // ... 'custom' => [ 'driver' => 'influxdb', 'name' => 'channel-name', 'level' => 'info', 'bubble' => true, ], // ... ], // ... ];
在你的代码中使用
Log::channel('custom')->info('Some message');
变更日志
查看所有变更日志 CHANGELOG
测试
$ git clone git@github.com/oanhnn/laravel-influxdb.git /path $ cd /path $ composer install $ composer test
贡献
请参阅 CONTRIBUTING 了解详细信息。
安全
如果您发现任何安全相关的问题,请通过电子邮件发送给 Oanh Nguyen,而不是使用问题跟踪器。
鸣谢
许可证
本项目采用 MIT 许可证发布。
版权 © Oanh Nguyen.