Giter VIP home page Giter VIP logo

graphite.js's Introduction

Graphite.js

a javascript client library for working with Graphite

Graphite.js provides a consistent, flexible way to interact with the Graphite render api. It has no external dependencies.

Getting started

Graphite.js provides a chainable api, with the special url method that returns a url corresponding to the accumulated property values. The minimum useful url requires a target (metric) to graph. The Graphite host is assumed to be "/render", but no other properties are provided default values. Instead, your Graphite server's configuration specifies what defaults it will use in generating graphs.

Graphite().url() == "/render";
Graphite().targets(["some.key"]).url() == "/render?target=some.key";
Graphite().host('http://metrics.biz/render')
          .targets(["some.key"])
          .url() == "http://metrics.biz/render?target=some.key";

Parameters can be initialized by providing a dictionary to the functor, or set by method chaining.

Graphite({
    from: "-2days",
    until: "now",
    height: "300",
    targets: ["some.key", "some.other.key"],
}).url();
Graphite()
  .from("-2days")
  .until("now")
  .height("300")
  .targets([
    "some.key",
    "some.other.key"
  ]);
// not recommended, but still works
Graphite()({from: "-2days"})({height: "300"}).targets(["bad.ideas"])().url();

Method names match parameters in the Graphite api documentation, with the following exceptions:

  • host is added to provide customization of the graphite host location
  • target is not present, since graphite expects multiple values of target with multiple keys. Instead, targets is provided and expects an array of values for graph targets
  • url is a getter only that returns the url corresponding to the current internal state.

A complete list of valid parameters is in the source documentation. The Graphite object uses the closures with getter-setter methods pattern for all properties.

var g = Graphite({
    host: "/render",
}).host("http://metrics.biz/render");
g.host() == "http://metrics.biz/render";

However, it does no error checking. You are responsible for making sure you're passing legal values.

Graphite().graphType("lolwut?").url() == "/render?graphType=lolwut?";
Graphite().graphType("1337").url() == "/render?graphType=1337";

Tests

Graphite.js uses qunit to run the tests. Crack open your web browser of choice and load testRunner.html to get started.

graphite.js's People

Contributors

lonnen avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.