PHP Classes
elePHPant
Icontem

PHP KairosDB Client: Connect and execute queries on KairosDB

Recommend this page to a friend!
  Info   View files Documentation   View files View files (11)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2015-06-13 (3 years ago) RSS 2.0 feedNot yet rated by the usersTotal: 67 All time: 9,399 This week: 700Up
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
Name: Daniel Martinez <contact>
Classes: 3 packages by
Country: Spain Spain
Age: 33
All time rank: 158935 in Spain Spain
Week rank: 729 Up26 in Spain Spain Up
Innovation award
Innovation award
Nominee: 2x

Details

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  
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  /  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  /  tests  
File Role Description
Files folder imageunit (1 file)

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

 Version Control Unique User Downloads Download Rankings  
 100%
Total:67
This week:0
All time:9,399
This week:700Up