Giter Club home page Giter Club logo

laraflux's Introduction

Maintained by Powerdatahub.com

Laravel Influxdb

A service made to provide, set up and use influxdb-php in Laravel 5.6

Installation

Follow this steps to use this package on your Laravel installation

1. Require it on composer

composer require power-data-hub/laraflux

The package will automatically register it's service provider.

For Laravel <= 5.4 add the provider manually

2. Load service provider (optional Laravel <= 5.4 only)

You need to update your config/app.php configuration file to register our service provider, adding this line on providers array:

PowerDataHub\Laraflux\ServiceProvider::class
'aliases' => [
//  ...
    'Laraflux' => PowerDataHub\Laraflux\Facades\Laraflux::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
  • Write this into your terminal inside your project
php artisan vendor:publish

Reading Data

<?php

// executing a query will yield a resultset object
$result = Laraflux::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 = [
    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 = Laraflux::writePoints($points, \InfluxDB\Database::PRECISION_SECONDS);

License

This project is licensed under the MIT License

laraflux's People

Contributors

dependabot-preview[bot] avatar dependabot-support avatar edbizarro avatar

Stargazers

 avatar  avatar

Watchers

 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.