prometheus

package
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

prometheus implements a Prometheus-compatible metrics exporter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Listen represents a net.Dial compatible string indicating the network address to bind the Prometheus metrics
	// scraping endpoint server. If not specified, the server won't be started.
	Listen string `yaml:"listen"`

	// FlushInterval represents the time interval in seconds at which the metrics reporter's registry metrics are
	// flushed to the Prometheus registry.
	FlushInterval int `yaml:"flush_interval"`

	// Namespace represents the namespace to apply to registered Prometheus metrics.
	Namespace string `yaml:"namespace"`

	// Subsystem represents the subsystem to apply to registered Prometheus metrics.
	Subsystem string `yaml:"subsystem"`

	// Debug represents a flags indicating whether to enable internal exporter activity logging.
	// This is mainly for debug purposes.
	Debug bool `yaml:"debug"`
}

Config represents a prometheus metrics export configuration.

type Exporter

type Exporter struct {
	*debug.D
	// contains filtered or unexported fields
}

Exporter represents a metrics exporter to a Prometheus server.

func New

func New(config *Config, registry metrics.Registry) (*Exporter, error)

New returns a new Prometheus metrics exporter based on provided configuration. If a go-metrics registry is provided, it is hooked into the exporter's internal Prometheus registry and its metrics will be flushed periodically to the Prometheus endpoint (flush interval to be specified in the config).

func (*Exporter) HTTPHandler

func (e *Exporter) HTTPHandler() http.Handler

HTTPHandler returns an HTTP.Handler exposing the Prometheus exporter registry.

func (*Exporter) MustRegister

func (e *Exporter) MustRegister(m prom.Collector)

MustRegister registers the provided metric to the Prometheus exporter registry, and panics if an error occur.

func (*Exporter) Register

func (e *Exporter) Register(m prom.Collector) error

Register registers the provided metric to the Prometheus exporter registry.

func (*Exporter) Start

func (e *Exporter) Start(ctx context.Context) error

Start starts the metrics exporter.

func (*Exporter) Stop

func (e *Exporter) Stop(_ context.Context) error

Stop stops the metrics exporter.

Jump to

Keyboard shortcuts

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