Mike Bostock edited this page Apr 16, 2013 · 14 revisions

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("");

# 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(*.*,'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); // ["", "", etc.]

# graphite.toString()

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

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.