Movatterモバイル変換


[0]ホーム

URL:


graphite

package
v1.23.2Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2025 License:Apache-2.0Imports:12Imported by:50

Details

Repository

github.com/prometheus/client_golang

Links

Documentation

Overview

Package graphite provides a bridge to push Prometheus metrics to a Graphiteserver.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

typeBridge

type Bridge struct {// contains filtered or unexported fields}

Bridge pushes metrics to the configured Graphite server.

Example
b, err := NewBridge(&Config{URL:           "graphite.example.org:3099",Gatherer:      prometheus.DefaultGatherer,Prefix:        "prefix",Interval:      15 * time.Second,Timeout:       10 * time.Second,ErrorHandling: AbortOnError,Logger:        log.New(os.Stdout, "graphite bridge: ", log.Lshortfile),})if err != nil {panic(err)}go func() {// Start something in a goroutine that uses metrics.}()// Push initial metrics to Graphite. Fail fast if the push fails.if err := b.Push(); err != nil {panic(err)}// Create a Context to control stopping the Run() loop that pushes// metrics to Graphite.ctx, cancel := context.WithCancel(context.Background())defer cancel()// Start pushing metrics to Graphite in the Run() loop.b.Run(ctx)

funcNewBridge

func NewBridge(c *Config) (*Bridge,error)

NewBridge returns a pointer to a new Bridge struct.

func (*Bridge)Push

func (b *Bridge) Push()error

Push pushes Prometheus metrics to the configured Graphite server.

func (*Bridge)Run

func (b *Bridge) Run(ctxcontext.Context)

Run starts the event loop that pushes Prometheus metrics to Graphite at theconfigured interval.

typeConfig

type Config struct {// Whether to use Graphite tags or not. Defaults to false.UseTagsbool// The url to push data to. Required.URLstring// The prefix for the pushed Graphite metrics. Defaults to empty string.Prefixstring// The interval to use for pushing data to Graphite. Defaults to 15 seconds.Intervaltime.Duration// The timeout for pushing metrics to Graphite. Defaults to 15 seconds.Timeouttime.Duration// The Gatherer to use for metrics. Defaults to prometheus.DefaultGatherer.Gathererprometheus.Gatherer// The logger that messages are written to. Defaults to no logging.LoggerLogger// ErrorHandling defines how errors are handled. Note that errors are// logged regardless of the configured ErrorHandling provided Logger// is not nil.ErrorHandlingHandlerErrorHandling}

Config defines the Graphite bridge config.

typeHandlerErrorHandling

type HandlerErrorHandlingint

HandlerErrorHandling defines how a Handler serving metrics will handleerrors.

const (// Ignore errors and try to push as many metrics to Graphite as possible.ContinueOnErrorHandlerErrorHandling =iota// Abort the push to Graphite upon the first error encountered.AbortOnError)

These constants cause handlers serving metrics to behave as described iferrors are encountered.

typeLogger

type Logger interface {Println(v ...interface{})}

Logger is the minimal interface Bridge needs for logging. Note thatlog.Logger from the standard library implements this interface, and it iseasy to implement by custom loggers, if they don't do so already anyway.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp