New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

elemenx/laravel-influxdb

A service made to provide, set up and use the library influxdb-php in Laravel.
2,641
Install
composer require elemenx/laravel-influxdb
Latest Version:0.0.2
PHP:^7.1.3
Laravel:5 · 6 · 7
License:MIT
Last Updated:Oct 25, 2021
Links: GitHub  ·  Packagist
Maintainer: branchzero

Laravel InfluxDB

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

A service made to provide, set up and use the library influxdb-php in Laravel.

Requirements

  • php >=7.1.3
  • Laravel 5.5+
  • influxdb-php 1.14+

Installation

Begin by pulling in the package through Composer.

$ composer require oanhnn/laravel-influxdb

Usage

Reading Data

<?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();

Writing Data

<?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);

Logging

NOTE This feature is available on Laravel version 5.6+.

In config/logging.php file, config you log with driver influxdb

<?php
return [
    // ...
    'channels' => [
        // ...
        'custom' => [
            'driver' => 'influxdb',
            'name'   => 'channel-name',
            'level'  => 'info',
            'bubble' => true,
        ],
        // ...
    ],
    // ...
];

In your code using

Log::channel('custom')->info('Some message');

Changelog

See all change logs in CHANGELOG

Testing

$ git clone git@github.com/oanhnn/laravel-influxdb.git /path
$ cd /path
$ composer install
$ composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email to Oanh Nguyen instead of using the issue tracker.

Credits

License

This project is released under the MIT License.
Copyright © Oanh Nguyen.

Related Packages

laragear/meta

A Laravel Package helper for Laravel Packages

1,346,523 7
cleaniquecoders/laravel-helper

Built with Laravel Standalone Package Creator

10,396 4
ipunkt/laravel-package-manager

Package Manager for laravel packages

1,744 2
wi-development/media

Admin's media

50 0
wi-development/locale

Admin's locale

49 0

Version History

Version Released PHP Laravel License
0.0.2 ^7.1.3 ^5.5|^6.0|^7.0 MIT
0.0.1 ^7.1.3 ^5.5|^6.0|^7.0 MIT