carbon-relay-ng

module
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2019 License: BSD-2-Clause-Views

README

Circle CI Go Report Card GoDoc

carbon-relay-ng

A relay for carbon streams, in go. Like carbon-relay from the graphite project, except it:

  • performs better: should be able to do about 100k ~ 1M million metrics per second depending on configuration and CPU speed.
  • you can adjust the routing table at runtime, in real time using the web or telnet interface (this feature has rough edges and is not production ready)
  • has aggregator functionality built-in for cross-series, cross-time and cross-time-and-series aggregations.
  • supports plaintext and pickle graphite routes (output) and metrics2.0/grafana.net, as well as kafka, Google PubSub and Amazon CloudWatch.
  • graphite routes supports a per-route spooling policy. (i.e. in case of an endpoint outage, we can temporarily queue the data up to disk and resume later)
  • performs validation on all incoming metrics (see below)
  • supported inputs: plaintext, pickle and AMQP (rabbitmq)

This makes it easy to fanout to other tools that feed in on the metrics. Or balance/split load, or provide redundancy, or partition the data, etc. This pattern allows alerting and event processing systems to act on the data as it is received (which is much better than repeated reading from your storage)

screenshot

Documentation

Concepts

You have 1 master routing table. This table contains 0-N routes. There's different route types. A carbon route can contain 0-M destinations (tcp endpoints)

First: "matching": you can match metrics on one or more of: prefix, substring, or regex. All 3 default to "" (empty string, i.e. allow all). The conditions are AND-ed. Regexes are more resource intensive and hence should - and often can be - avoided.

  • All incoming metrics are validated and go into the table when valid.

  • The table will then check metrics against the blacklist and discard when appropriate.

  • Then metrics pass through the rewriters and are modified if applicable. Rewrite rules wrapped with forward slashes are interpreted as regular expressions.

  • The table sends the metric to:

    • the aggregators, who match the metrics against their rules, compute aggregations and feed results back into the table. see Aggregation section below for details.
    • any routes that matches
  • The route can have different behaviors, based on its type:

    • for grafanaNet / kafkaMdm / Google PubSub routes, there is only a single endpoint so that's where the data goes. For standard/carbon routes you can control how data gets routed into destinations (note that destinations have settings to match on prefix/sub/regex, just like routes):
    • sendAllMatch: send all metrics to all the defined endpoints (possibly, and commonly only 1 endpoint).
    • sendFirstMatch: send the metrics to the first endpoint that matches it.
    • consistentHashing: the algorithm is the same as Carbon's consistent hashing.
    • round robin: the route is a RR pool (not implemented)

carbon-relay-ng (for now) focuses on staying up and not consuming much resources.

For carbon routes:

  • if connection is up but slow, we drop the data
  • if connection is down and spooling enabled. we try to spool but if it's slow we drop the data
  • if connection is down and spooling disabled -> drop the data

kafka, Google PubSub, and grafanaNet have an in-memory buffer and can be configured to blocking or non-blocking mode when the buffer runs full.

Directories

Path Synopsis
cmd
carbon-relay-ng
carbon-relay-ng route traffic to anything that speaks the Graphite Carbon protocol (text or pickle) such as Graphite's carbon-cache.py, influxdb, ...
carbon-relay-ng route traffic to anything that speaks the Graphite Carbon protocol (text or pickle) such as Graphite's carbon-cache.py, influxdb, ...
like bufio.Writer (Copyright 2009 The Go Authors.
like bufio.Writer (Copyright 2009 The Go Authors.
package whisper is a copy of some stuff we need from https://github.com/go-graphite/go-whisper in particular, it removes flock stuff which doesn't build on windows
package whisper is a copy of some stuff we need from https://github.com/go-graphite/go-whisper in particular, it removes flock stuff which doesn't build on windows
Package logger provides a custom TextFormatter for use with the github.com/sirupsen/logrus library.
Package logger provides a custom TextFormatter for use with the github.com/sirupsen/logrus library.
package persister is a copy of github.com/lomik/go-carbon/persister with non essential stuff removed, and using a fork of go-whisper, which allows us to build on windows this is a parser for graphite's storage-schemas.conf it supports old and new retention format see https://graphite.readthedocs.io/en/0.9.9/config-carbon.html#storage-schemas-conf based on https://github.com/grobian/carbonwriter but with some improvements
package persister is a copy of github.com/lomik/go-carbon/persister with non essential stuff removed, and using a fork of go-whisper, which allows us to build on windows this is a parser for graphite's storage-schemas.conf it supports old and new retention format see https://graphite.readthedocs.io/en/0.9.9/config-carbon.html#storage-schemas-conf based on https://github.com/grobian/carbonwriter but with some improvements
Package stats provides functionality for instrumenting metrics and reporting them The metrics can be user specified, or sourced from the runtime (reporters) To use this package correctly, you must instantiate exactly 1 output.
Package stats provides functionality for instrumenting metrics and reporting them The metrics can be user specified, or sourced from the runtime (reporters) To use this package correctly, you must instantiate exactly 1 output.
ui
web

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL