graphite

package module
v0.0.0-...-a84bd1e Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2017 License: BSD-2-Clause Imports: 8 Imported by: 0

README

This is a reporter for the go-metrics library which will post the metrics to Graphite. It was originally part of the go-metrics library itself, but has been split off to github.com/cyberdelia/go-metrics-graphite and then forked here.

cyberdelia's version needs a resolved net.TCPAddr which makes it fragile in dynamic environments, where Graphite address can points to distributed cluster where specific hosts can change. Starting your app with cyberdelia version means that you can loose its metrics when one of Graphite hosts in cluster will be replaced.

This fork provides an interface with address provided as a string. You can provide a DNS name to it and it will resolve metrics target before each flush operation, so you can swap Graphite hosts and send app metrics to new location without restarting it.

Usage

import "github.com/kamilchm/go-metrics-graphite"


go graphite.Graphite(metrics.DefaultRegistry,
  1*time.Second, "some.prefix", "graphite-cluster:2003")

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Graphite

func Graphite(r metrics.Registry, d time.Duration, prefix string, addr string)

Graphite is a blocking exporter function which reports metrics in r to a graphite server located at addr, flushing them every d duration and prepending metric names with prefix.

Example
go Graphite(metrics.DefaultRegistry, 1*time.Second, "some.prefix", "net:2003")
Output:

func Once

func Once(c Config) error

Once performs a single submission to Graphite, returning a non-nil error on failed connections. This can be used in a loop similar to GraphiteWithConfig for custom error handling.

func WithConfig

func WithConfig(c Config)

WithConfig is a blocking exporter function just like Graphite, but it takes a GraphiteConfig instead.

Example
go WithConfig(Config{
	Addr:          "net:2002",
	Registry:      metrics.DefaultRegistry,
	FlushInterval: 1 * time.Second,
	DurationUnit:  time.Millisecond,
	Percentiles:   []float64{0.5, 0.75, 0.99, 0.999},
})
Output:

Types

type Config

type Config struct {
	Addr          string           // Graphite address to connect to
	Registry      metrics.Registry // Registry to be exported
	FlushInterval time.Duration    // Flush interval
	DurationUnit  time.Duration    // Time conversion unit for durations
	Prefix        string           // Prefix to be prepended to metric names
	Percentiles   []float64        // Percentiles to export from timers and histograms
}

Config provides a container with configuration parameters for the Graphite exporter

Jump to

Keyboard shortcuts

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