statsdexporter

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2022 License: MIT Imports: 18 Imported by: 0

README

statsdexporter

PkgGoDev

Helper library for embedding https://github.com/prometheus/statsd_exporter as a library

See tests for example usage.

LICENSE

See LICENSE

This project is not an official project of any employer past or present. This project was done using personal equipment, accounts, and time.

Documentation

Overview

Package statsdexporter is a helper for embedded statsd_exporter in other projects.

Index

Constants

This section is empty.

Variables

View Source
var (

	// Metrics can be used to register metrics about the exporter itself
	Metrics = []prometheus.Collector{
		eventStats,
		eventsFlushed,
		eventsUnmapped,
		udpPackets,
		tcpConnections,
		tcpErrors,
		tcpLineTooLong,
		unixgramPackets,
		linesReceived,
		samplesReceived,
		sampleErrors,
		tagsReceived,
		tagErrors,
		conflictingEventStats,
		errorEventStats,
		eventsActions,
		metricsCount,
	}
)

Functions

This section is empty.

Types

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option is used when creating a new exporter.

func WithAddress

func WithAddress(network string, addr string) Option

WithAddress sets the address for the listener. Default is a random UDP port on localhost.

func WithCacheSize

func WithCacheSize(size uint) Option

WithCacheSize sets the maximum size of your metric mapping cache.

Default is 1000.

func WithCacheType

func WithCacheType(cacheType string) Option

WithCacheType sets metric mapping cache type. Valid options are "lru" and "random".

Default is "lru".

func WithDogstatsdTagsEnabled

func WithDogstatsdTagsEnabled(enabled bool) Option

WithDogstatsdTagsEnabled sets whether to parse DogStatsd style tags.

Default is true.

func WithEventFlushInterval

func WithEventFlushInterval(interval time.Duration) Option

WithEventFlushInterval sets the maximum time between event queue flushes.

Default is 200ms

func WithEventFlushThreshold

func WithEventFlushThreshold(size uint) Option

WithEventFlushThreshold sets the number of events to hold in queue before flushing.

Default is 1000.

func WithEventQueueSize

func WithEventQueueSize(size uint) Option

WithEventQueueSize sets the size of internal queue for processing events.

Default is 10000.

func WithInfluxdbTagsEnabled

func WithInfluxdbTagsEnabled(enabled bool) Option

WithInfluxdbTagsEnabled sets whether to parse InfluxDB style tags.

Default is true.

func WithLibratoTagsEnabled

func WithLibratoTagsEnabled(enabled bool) Option

WithInfluxdbTagsEnabled sets whether to parse Librato style tags.

Default is true.

func WithLogger

func WithLogger(logger log.Logger) Option

WithLogger sets the logger to use. A nop is used by default.

func WithMappingConfig

func WithMappingConfig(configFile string) Option

WithMappingConfig sets the metric mapping configuration file name.

func WithReadBuffer

func WithReadBuffer(size uint) Option

WithReadBuffer sets the read buffer size (in bytes) of the operating system's transmit read buffer associated with the UDP or Unixgram connection. Please make sure the kernel parameters net.core.rmem_max is set to a value greater than the value specified.

func WithRegWithGathereristerer

func WithRegWithGathereristerer(gatherer prometheus.Gatherer) Option

WithGatherer sets the Gatherer to sue for registering metrics. The gatherer and register should use the same underlying prometheus registry for metrics to work as expected.

Default is prometheus.DefaultGathererer.

func WithRegisterer

func WithRegisterer(registerer prometheus.Registerer) Option

WithRegisterer sets the Registerer to sue for registering metrics.

Default is prometheus.DefaultRegisterer.

func WithSignalFXTagsEnabled

func WithSignalFXTagsEnabled(enabled bool) Option

WithInfluxdbTagsEnabled sets whether to parse SignalFX style tags.

Default is true.

func WithUnixSocketMode

func WithUnixSocketMode(mode os.FileMode) Option

WithUnixSocketMode sets the file mode when using a unix socket. Default is 0o755

type Server

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

Server is a statsd server

func New

func New(options ...Option) (*Server, error)

func (*Server) Reload

func (s *Server) Reload() error

Reload the mapping config, if set

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run until the context is cancelled.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP can be used as an http Handler for /metrics

func (*Server) WaitForAddress

func (s *Server) WaitForAddress(ctx context.Context) (net.Addr, error)

WaitForAddress is useful when using a random port.

Jump to

Keyboard shortcuts

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