Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

This package is a Laravel wrapper for the influxdb-php client.

NotificationsYou must be signed in to change notification settings

ge-tracker/influxdb-laravel

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This package is a Laravel wrapper for theinfluxdb-php client. We utilisegraham-campbell/manager to provide multiple connection interfaces.

Installation

This package requires PHP 7.1+, and supports Laravel 5.6 - 8.

  1. To install the latest version of the package, run the following command in your terminal:

    composer require ge-tracker/influxdb-laravel

    Laravel will auto-discover the package's service provider, located atGeTracker\InfluxDBLaravel\InfluxDBLaravelServiceProvider.

  2. Next, you should publish the application's configuration file

    php artisan vendor:publish

Configuration

This package's configuration, after publishing, will be located atconfig/influxdb.php.

Default Connection Name

This option ('default') is where you may specify which of the connections below you wish to use as your default connection for all work. Of course, you may use many connections at once using the manager class. The default value for this setting is'main'.

InfluxDB Connections

This option ('connections') is where each of the connections are setup for your application. An example configuration has been included, but you may add as many connections as you would like.

Usage

The underlying InfluxDB connection instance can be accessed via Facade or Dependency Injection. Unless specified, the package will use themain connection by default.

Facade

<?php// create an array of points$points =array(newInfluxDB\Point('test_metric',// name of the measurementnull,// the measurement value        ['host' =>'server01','region' =>'us-west'],// optional tags        ['cpucount' =>10],// optional additional fieldstime()// Time precision has to be set to seconds!    ),newInfluxDB\Point('test_metric',// name of the measurementnull,// the measurement value        ['host' =>'server01','region' =>'us-west'],// optional tags        ['cpucount' =>10],// optional additional fieldstime()// Time precision has to be set to seconds!    ));$result = InfluxDB::writePoints($points, \InfluxDB\Database::PRECISION_SECONDS);

Dependency Injection

DI can be used by type-hinting theInfluxDBManager class:

<?phpnamespaceApp;useGeTracker\InfluxDBLaravel\InfluxDBManager;class Foo{/** @var InfluxDBManager */protected$influxDb;publicfunction__construct(InfluxDBManager$influxDb)    {$this->influxDB =$influxDB;    }publicfunctionbar()    {return$this->influxDb->getQueryBuilder()            ->select('usage, idle')            ->from('cpu')            ->where(['time < now() -1d',"host='host01'",            ])            ->getResultSet();    }}

Connections

Both theInfluxDBManager andInfluxDB facade provide aconnection() method, which will allow another InfluxDB connection to be interacted with:

// The `main` connection will be used$manager->query("SELECT * FROM cpu");// The `alternative` connection will be used$manager->connection('alternative')->query("SELECT * FROM cpu");

Credits

About

This package is a Laravel wrapper for the influxdb-php client.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp