GithubHelp home page GithubHelp logo

laravel-influxdb's Introduction

Laravel Influxdb

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

Installing

  • Install by composer command:
composer require tray-labs/laravel-influxdb
  • Or add this line to require section of composer.json and execute on your terminal $ composer install
"require": {
    "tray-labs/laravel-influxdb": "^1.0"
}

This package use auto-discover, if using less than version laravel 5.5 you must use below settings

  • Add this lines to yours config/app.php (Use only with Laravel version less than 5.5 )
'providers' => [
//  ...
    TrayLabs\InfluxDB\Providers\ServiceProvider::class,
]
'aliases' => [
//  ...
    'InfluxDB' => TrayLabs\InfluxDB\Facades\InfluxDB::class,
]
  • Define env variables to connect to InfluxDB
INFLUXDB_HOST=localhost
INFLUXDB_PORT=8086
INFLUXDB_USER=some_user
INFLUXDB_PASSWORD=some_password
INFLUXDB_SSL=false
INFLUXDB_VERIFYSSL=false
INFLUXDB_TIMEOUT=0
INFLUXDB_DBNAME=some_database
INFLUXDB_UDP_ENABLED=false # Activate UDP
INFLUXDB_UDP_PORT=4444 # Port for UDP
  • Write this into your terminal inside your project
php artisan vendor:publish

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

License

This project is licensed under the MIT License

laravel-influxdb's People

Contributors

dsandrade avatar tray-labs avatar charlesbilbo avatar tobias-kuendig avatar edbizarro avatar 1giba avatar swilla avatar cyrrill avatar kuenzelit avatar

Watchers

Daniel Alvarez avatar Daniel Leach avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.