pdffiller/laravel-influx-provider

This package is abandoned and no longer maintained. No replacement package was suggested.

Service provider to set up and use InfluxDB SDK in Laravel 5

Package info

github.com/pdffiller/laravel-influx-provider

pkg:composer/pdffiller/laravel-influx-provider

Statistics

Installs: 6 374

Dependents: 0

Suggesters: 0

Stars: 18

Open Issues: 0

v1.6.6 2019-12-03 17:09 UTC

Requires

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT ffe8ed386fca952972d9b0b67cfa9533f812ee9c

  • Anton Balandin <anbalandin.woop@gmail.com>

laravelinflux-db

This package is auto-updated.

Last update: 2025-03-20 14:11:39 UTC


README

A minimal service provider to set up and use InfluxDB SDK in Laravel 5

Installation

  • Add a line to the require section of composer.json and execute $ composer install
"require": {
// ...
 "pdffiller/laravel-influx-provider": "^1.6"
}
  • Add these lines to config/app.php
'providers' => [
// ...
 Pdffiller\LaravelInfluxProvider\InfluxDBServiceProvider::class,
]


'aliases' => [
// ...
 'Influx' => Pdffiller\LaravelInfluxProvider\InfluxDBFacade::class,
]
  • Define env variables to connect to InfluxDB
LARAVEL_INFLUX_PROVIDER_PROTOCOL=http
LARAVEL_INFLUX_PROVIDER_USER=some_user
LARAVEL_INFLUX_PROVIDER_PASSWORD=some_password
LARAVEL_INFLUX_PROVIDER_HOST=host
LARAVEL_INFLUX_PROVIDER_PORT=8086
LARAVEL_INFLUX_PROVIDER_DATABASE=database_name
LARAVEL_INFLUX_PROVIDER_VERIFY_SSL=false
LARAVEL_INFLUX_PROVIDER_TIMEOUT=0
LARAVEL_INFLUX_PROVIDER_CONNECT_TIMEOUT=0

How to use

$client = new \Influx;
$data = $client::query('SELECT * from "data" ORDER BY time DESC LIMIT 1');
$point = [
 new \InfluxDB\Point(
 'name' => 'some_name',
 'value' => 1, // some value for some_name
 'tags' => [
 // array of string values
 ],
 'fields' => [
 // array of numeric values
 ],
 'timestamp' => exec('date +%s%N') // timestamp in nanoseconds on Linux ONLY
 )
];
try {
 Influx::writePoints($point);
} catch (\InfluxDB\Exception $e) {
 // something is wrong, track this
}

Also you can send data to another database like this:

Influx::selectDB($dbName)->writePoints($point);

License

airSlate and any contributors to this project each grants you a license, under its respective copyrights, to the Laravel InfluxDB provider and other content in this repository under the MIT License, see the LICENSE file for more information.