Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

till/Services_Librato

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Services\Librato

This is a work in progress where we implement the Librato API as we move forward.

Current work in progress: Services\Librato\Metrics:

  • 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.

A metric is created with the following code:

<?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:

<?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:

<?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!

Services\Librato\Annotations

One can also create and retrieve annotations. Here is an example:

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

License

New BSD License.

About

An API-wrapper for Librato.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages