2017 © Pedro Peláez
 

library services_librato

PHP API wrapper for Librato's metric service

image

till/services_librato

PHP API wrapper for Librato's metric service

  • Tuesday, October 23, 2012
  • by till
  • Repository
  • 1 Watchers
  • 9 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 2 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Services\Librato

This is a work in progress where we implement the Librato API as we move forward., (*1)

Current work in progress: Services\Librato\Metrics:, (*2)

  • delete metrics
  • publish metrics
  • get metrics

Services\Librato\Metrics

The most interesting bit is publishing metrics. Currently, you can public an individual metric, or multiple., (*3)

A metric is created with the following code:, (*4)

<?php
use Services\Librato\Metrics\Metric;
$metric         = new Metric('counter);
$metric->value  = 1;
$metric->source = 'production'; // this is optional

By default my code assumes 'gauges', so in order to send a counter, you'll have to do the following:, (*5)

<?php
use Services\Librato\Metrics;
use Services\Librato\Metrics\Counters;
// create metric

$counters = new Counters();
$counters->accept($metric);

$metrics = new Metrics('youremail', 'yourapikey');
var_dump($metrics->update($counters)); // should output 'true'

If you'd like to mix counters and gauges and submit them in one request (preferrable :)) use a SuperCollection:, (*6)

<?php
use Services\Librato\Metrics;
use Services\Librato\Metrics\Counters;
use Services\Librato\Metrics\Gauges;
use Services\Librato\Metrics\SuperCollection;

// create metrics
$counters = new Counters;
$counters->accept($metric);

$gauges = new Gauges;
$gauges->accept($anotherMetric);

$collection = new SuperCollection;
$collection->accept($counters)->accept($gauges);

$metrics = new Metrics('youremail', 'yourapikey');
var_dump($metrics->update($counters)); // should output 'true'

For more, check out the examples directory!, (*7)

Services\Librato\Annotations

One can also create and retrieve annotations. Here is an example:, (*8)

<?php
use Services\Librato\Annotations;
$annotations = new Annotations($user, $apiKey);
$annotations->create('streamName', 'title', 'source', 'desc', time() - 60, time() - 5);

License

New BSD License., (*9)

The Versions

23/10 2012

dev-master

9999999-dev

PHP API wrapper for Librato's metric service

  Sources   Download

BSD-2-Clause

The Requires

  • php >=5.3.0
  • pear-pear/http_request2 2.1.1

 

23/10 2012

1.0.0-alpha1

1.0.0.0-alpha1

PHP API wrapper for Librato's metric service

  Sources   Download

BSD-2-Clause

The Requires

  • php >=5.3.0
  • pear-pear/http_request2 2.1.1