Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Graphite has a nice simple JSON API, which means we can shift rendering from boring JPGs to exicting JavaScript visualisations.

Quickstart

npm install
./test.sh
open example.html

Example

Here's the library talking to The Guardian's Graphite API, fed in to Rickshaw.

Usage

This is written as an AMD module, so you can include it in an HTML page like so,

curl(['lib/graphite.js'])
    .then(function(graphite) {
        var g = new graphite.client();
    })

Basics

Create a simple graph URL with two targets,

var g = new graphite.client( { host: 'http://foo.com/render' } )
g.targets.push('bar.sum', 'foo.sum');
g.toUrl() // http://foo.com/render?target=bar.sum&target=foo.sum&from=-1hours

... you could put the output of the toURL() function in to the src of an <img> tag for example.

JSON

Or we could ask for a JSON object from the last 24 hours,

var g = new graphite.client({ format: 'json', 'from': '-24hours' })
g.targets.push('bar.sum', 'foo.sum');
g.toUrl() // http://graphite.example.com/render?target=bar.sum&target=foo.sum&from=-24hours&format=json&jsonp=?

Functions

Create a graph with functions around the series data,

var g = new graphite.client()
g.targets.push(
    new graphite.target('graphite.GU-PROD-Frontend')
      .exclude('__SummaryInfo__')
      .averageSeries()
      .alias('200s')
      .toQueryString()
    )
g.toUrl() // ...alias(averageSeries(exclude(graphite.GU-PROD-Frontend,"__SummaryInfo__")),"foo")

The order of the functions that are chained is important. The first, after target(n), will form the innermost function around the target, the second the function around that, and so on, until the last function, which will wrap the whole chain.

So,

g.targets.push(
    new graphite.target('abc')
      .foo()  <---- the first function
      .bar("123")
    )

Results in,

bar(foo(abc),"123")  <---- foo() forms the innermost function, around the target 'abc'

About

No description, website, or topics provided.

Resources

Releases

No releases published
You can’t perform that action at this time.