Version: v0.2.0 Latest Latest

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

Go to latest
Published: Oct 27, 2015 License: MIT, MIT Imports: 14 Imported by: 0



Each UDP input allows the binding address, target database, and target retention policy to be set. If the database does not exist, it will be created automatically when the input is initialized. If the retention policy is not configured, then the default retention policy for the database is used. However if the retention policy is set, the retention policy must be explicitly created. The input will not automatically create it.

Each UDP input also performs internal batching of the points it receives, as batched writes to the database are more efficient. The default batch size is 1000, pending batch factor is 5, with a batch timeout of 1 second. This means the input will write batches of maximum size 1000, but if a batch has not reached 1000 points within 1 second of the first point being added to a batch, it will emit that batch regardless of size. The pending batch factor controls how many batches can be in memory at once, allowing the input to transmit a batch, while still building other batches.


The UDP input can receive up to 64KB per read, and splits the received data by newline. Each part is then interpreted as line-protocol encoded points, and parsed accordingly.

UDP is connectionless

Since UDP is a connectionless protocol there is no way to signal to the data source if any error occurs, and if data has even been successfully indexed. This should be kept in mind when deciding if and when to use the UDP input. The built-in UDP statistics are useful for monitoring the UDP inputs.




View Source
const (
	// DefaultDatabase is the default database for UDP traffic.
	DefaultDatabase = "udp"

	// DefaultBatchSize is the default UDP batch size.
	DefaultBatchSize = 1000

	// DefaultBatchPending is the default number of pending UDP batches.
	DefaultBatchPending = 5

	// DefaultBatchTimeout is the default UDP batch timeout.
	DefaultBatchTimeout = time.Second
View Source
const (
	UDPBufferSize = 65536


This section is empty.


This section is empty.


type Config

type Config struct {
	Enabled     bool   `toml:"enabled"`
	BindAddress string `toml:"bind-address"`

	Database        string        `toml:"database"`
	RetentionPolicy string        `toml:"retention-policy"`
	BatchSize       int           `toml:"batch-size"`
	BatchPending    int           `toml:"batch-pending"`
	BatchTimeout    toml.Duration `toml:"batch-timeout"`

func (*Config) WithDefaults added in v0.2.0

func (c *Config) WithDefaults() *Config

WithDefaults takes the given config and returns a new config with any required default values set.

type Service

type Service struct {
	PointsWriter interface {
		WritePoints(p *cluster.WritePointsRequest) error

	MetaStore interface {
		CreateDatabaseIfNotExists(name string) (*meta.DatabaseInfo, error)

	Logger *log.Logger
	// contains filtered or unexported fields

Service represents here an UDP service that will listen for incoming packets formatted with the inline protocol

func NewService

func NewService(c Config) *Service

func (*Service) Addr

func (s *Service) Addr() net.Addr

func (*Service) Close

func (s *Service) Close() error

func (*Service) Open

func (s *Service) Open() (err error)

func (*Service) SetLogger

func (s *Service) SetLogger(l *log.Logger)

SetLogger sets the internal logger to the logger passed in.

Jump to

Keyboard shortcuts

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