oanhnn/laravel-influxdb

一个旨在提供、设置和使用laravel中influxdb-php库的服务。

v0.1.0 2019-02-28 09:07 UTC

This package is auto-updated.

Last update: 2024-09-08 12:47:27 UTC


README

Latest Version Software License Build Status Coverage Status Total Downloads Requires PHP

一个旨在提供、设置和使用influxdb-php库在Laravel中的服务。

要求

  • 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