Skip to content
This repository

WikiAPI ReferenceGraphite

A source for Graphite metrics. To create a source, first create a context. Then, use context.graphite to specify the URL of the Graphite server. For example:

var context = cubism.context(), // a default context
    graphite = context.graphite("http://graphite.example.com");

# graphite.metric(expression)

Creates a new metric for the given Graphite expression. For example, if you were using Graphite in conjunction with Collectd's CPU plugin, you could monitor the CPU utilization of the machine "foo" by saying:

var foo = graphite.metric("sumSeries(nonNegativeDerivative(exclude(hosts.foo.cpu.*.*,'idle')))");

For more information on metric expressions, see Graphite's documentation on the target parameter.

When the step is 10 seconds, the metric is sent to Graphite as-is; for other step intervals, the metric will be summarized automatically using Graphite's summarize function. The default summation function is "sum", but you can change this using the returned metric's summarize function. For example, to summarize using average:

var foo = graphite.metric("foo").summarize("avg");

# graphite.find(pattern, callback)

Queries the Graphite server to look for metrics that match the specified pattern, invoking the specified callback when the results are available. The callback is passed two arguments: an error, if any, and an array of string results. For example, to see which hosts have CPU metrics available, you might say:

graphite.find("hosts.*.cpu.0", function(error, results) {
  console.log(results); // ["hosts.foo.cpu.0.", "hosts.bar.cpu.0.", etc.]
});

# graphite.toString()

Returns the URL of the Graphite server; the first argument to the constructor.

Something went wrong with that request. Please try again.