PHP Classes

PHP KairosDB Client: Connect and execute queries on KairosDB

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 69 All time: 10,304 This week: 455Up
Version License PHP version Categories
kairosdb-client 0.5Artistic License5.5PHP 5, Databases, Web services
Description 

Author

This package can connect and execute queries on KairosDB.

There is a client class that can send HTTP requests to a KairosDB server running on a given host and port.

A separate query builder class can be used to compose queries using parameters that define metrics, group by and limit clauses, tags, time limits and caching.

Innovation Award
PHP Programming Innovation award nominee
June 2015
Number 8
Apache Cassandra is a project that implements a database with high availability and high scalability. KairosDB is a distributed scalable time series database written on top of Cassandra.

This package provides a client to connect and execute queries on a KairosDB database.

Manuel Lemos
Picture of Daniel Martinez
Name: Daniel Martinez <contact>
Classes: 3 packages by
Country: Spain Spain
Age: 38
All time rank: 160036 in Spain Spain
Week rank: 180 Up6 in Spain Spain Up
Innovation award
Innovation award
Nominee: 2x

Documentation

KairosDB Client Build Status

Description

A client library for KairosDB written in PHP. This package provides convenience functions to read and write time series data. It uses the HTTP protocol to communicate with your KairosDB cluster.

Getting Started

Install (Composer)

$ composer require 'danibrutal/kairosdb-client:dev-master'

Connecting To Your Database

Connecting to an KairosDB database is straightforward. You will need a host name a port. The default port is 8080.

For more information please check out the KairosDB Docs.

Inserting Data

We can add a single data point:

require 'vendor/autoload.php';

$client = new KairosDB\Client('localhost', 8090);
$tags = ['host'=> 'precise64'];
$metricName = 'network_out';

for($i=2; $i<100; $i++) {
    $dataPointValue = $i *2;
    $client->addDataPoint($metricName, $dataPointValue, $tags);
    usleep(100);
}

Or using batch inserts:

require 'vendor/autoload.php';

$client = new \KairosDB\Client('localhost', 8090);
$tags = ['host'=> 'precise64'];
$metricName = 'network_out';

$dataPointCollection = new \KairosDB\DataPointCollection($metricName, $tags);

for($i=2; $i<100; $i++) {
    $dataPointValue = $i *2;    
    $dataPointCollection->addPoint($dataPointValue);
    usleep(100);
}

$client->addDataPoints($dataPointCollection);

Querying Data Points

The start date is required, but the end date defaults to NOW if not specified. The metric(s) that you are querying for is also required. Optionally, tags may be added to narrow down the search.

require 'vendor/autoload.php';

$client = new KairosDB\Client('localhost', 8090);

$queryBuilder = new \KairosDB\QueryBuilder();
$tags = ['host'=> 'precise64'];

$query = $queryBuilder
    ->start(['value'=> '1', 'unit' => 'days'])
    ->cache(10)
    ->addMetric('network_in')
    ->tags($tags)
    ->build();

$results = $client->query($query);

Querying Metric Names

You can get a list of all metric names in KairosDB.

require 'vendor/autoload.php';

$client = new KairosDB\Client('localhost', 8090);

$results = $client->getMetricNames($query);

Querying Tag Names

Similarly you can get a list of all tag names in KairosDB.

require 'vendor/autoload.php';

$client = new KairosDB\Client('localhost', 8090);

$results = $client->getTagNames($query);

Querying Tag Values

And a list of all tag values.

require 'vendor/autoload.php';

$client = new KairosDB\Client('localhost', 8090);

$results = $client->getTagValues($query);

Custom Data Types

TODO: implement

KairosDB Docs

Please refer to http://kairosdb.github.io/kairosdocs/ for documentation.


  Files folder image Files (11)  
File Role Description
Files folder imagesrc (3 files)
Files folder imagetests (1 directory)
Accessible without login Plain text file .gitignore Data Auxiliary data
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file LICENSE.md Lic. Auxiliary data
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Auxiliary data

  Files folder image Files (11)  /  src  
File Role Description
  Plain text file Client.php Class Class source
  Plain text file DataPointCollection.php Class Class source
  Plain text file QueryBuilder.php Class Class source

  Files folder image Files (11)  /  tests  
File Role Description
Files folder imageunit (1 file)

  Files folder image Files (11)  /  tests  /  unit  
File Role Description
  Accessible without login Plain text file QueryBuilderTest.php Test Unit test script

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:69
This week:0
All time:10,304
This week:455Up