1. Go to this page and download the library: Download ge-tracker/influxdb-laravel library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ge-tracker / influxdb-laravel example snippets
// create an array of points
$points = [
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);
namespace App;
use GeTracker\InfluxDBLaravel\InfluxDBManager;
class Foo
{
public function __construct(
protected InfluxDBManager $influxDb
) {
$this->influxDB = $influxDB;
}
public function bar()
{
return $this->influxDb->getQueryBuilder()
->select('usage, idle')
->from('cpu')
->where([
'time < now() -1d',
"host='host01'",
])
->getResultSet();
}
}
// The `main` connection will be used
$manager->query("SELECT * FROM cpu");
// The `alternative` connection will be used
$manager->connection('alternative')->query("SELECT * FROM cpu");
bash
$ php artisan vendor:publish
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.