定制 danibrutal/kairosdb-client 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

danibrutal/kairosdb-client

Composer 安装命令:

composer require danibrutal/kairosdb-client

包简介

A client library for KairosDB written in PHP

README 文档

README

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.

统计信息

  • 总下载量: 1.67k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-05-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固