relay

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2023 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultHTTPTimeout      = 10 * time.Second
	DefaultMaxDelayInterval = 10 * time.Second
	DefaultBatchSizeKB      = 512

	KB = 1024
	MB = 1024 * KB
)

Variables

View Source
var ErrBufferFull = errors.New("retry buffer full")
View Source
var RelayCache *cache.Cache

RelayCache is the in-mem cache used to store BeringeiPoint

Functions

func GraphiteMetric

func GraphiteMetric(metricName string, tags map[string]string, timestamp int64, value interface{}, field string) telegraf.Metric

GraphiteMetric transforms a BeringeiPoint to Graphite compatible format

func GraphiteWindowsMetric added in v0.5.1

func GraphiteWindowsMetric(metricName string, tags map[string]string, timestamp int64, value interface{}, field string) telegraf.Metric

GraphiteMetric transforms a BeringeiPoint to Graphite compatible format

func NewBeringeiBackend

func NewBeringeiBackend(cfg *BeringeiOutputConfig) (*beringeiBackend, error)

NewBeringeiBackend Initializes a new Beringei Backend

func NewGraphiteBackend

func NewGraphiteBackend(cfg *GraphiteOutputConfig) (*graphiteBackend, error)

NewGraphiteBackend Initializes a new Graphite Backend

Types

type Beringei

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

Beringei is a relay for Beringei writes

func (*Beringei) Name

func (b *Beringei) Name() string

func (*Beringei) Run

func (b *Beringei) Run() error

func (*Beringei) ServeHTTP

func (b *Beringei) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Beringei) Stop

func (b *Beringei) Stop() error

Stop stops the Beringei Relay

type BeringeiConfig

type BeringeiConfig struct {
	//Name identifies the beringei relay
	Name string `toml:"name"`

	// Addr is where the UDP relay will listen for packets
	Addr string `toml:"bind-addr"`

	// SSLCombinedPem set certificate in order to handle HTTPS requests
	SSLCombinedPem string `toml:"ssl-combined-pem"`

	// AMQPUrl will be used to connect to Rabbitmq (amqp://guest:guest@127.0.0.1:5672/)
	AMQPUrl string `toml:"amqp-url"`

	BeringeiUpdateURL string `toml:"beringei-update-url"`

	// Outputs is a list of backend servers where writes will be forwarded
	Outputs []BeringeiOutputConfig `toml:"output"`

	// GraphiteOutput is a list of graphite backends
	GraphiteOutput string `toml:"graphite-output"`
}

type BeringeiOutputConfig

type BeringeiOutputConfig struct {
	// Name identifies the Beringei backend
	Name string `toml:"name"`

	// Location should be set to the host:port of the backend server
	Location string `toml:"location"`
}

type BeringeiPoint

type BeringeiPoint struct {
	Name      string
	Timestamp int64
	Tags      map[string]string
	Field     string
	Value     interface{}
	ID        string
}

BeringeiPoint is the Point that we push to Rabbitmq

func NewBeringeiPoint

func NewBeringeiPoint(name, field string, timestamp int64, tags map[string]string, value interface{}) *BeringeiPoint

NewBeringeiPoint Initializes and returns a new BeringeiPoint

type Config

type Config struct {
	HTTPRelays     []HTTPConfig     `toml:"http"`
	UDPRelays      []UDPConfig      `toml:"udp"`
	BeringeiRelays []BeringeiConfig `toml:"beringei"`
	GraphiteRelays []GraphiteConfig `toml:"graphite"`
}

func LoadConfigFile

func LoadConfigFile(filename string) (cfg Config, err error)

LoadConfigFile parses the specified file into a Config object

type GraphiteConfig

type GraphiteConfig struct {
	// Name identifies the graphite relay
	Name string `toml:"name"`

	// Addr is where the Graphite Relay will listen for packets
	Addr string `toml:"bind-addr"`

	// SSLCombinedPem set certificate in order to handle HTTPS requests
	SSLCombinedPem string `toml:"ssl-combined-pem"`

	// EnableMetering toggles metering stats to Rabbitmq. You have to setup AMQPUrl for this
	EnableMetering bool `toml:"enable-metering"`

	// AMQPUrl will be used to connect to Rabbitmq (amqp://guest:guest@127.0.0.1:5672/)
	AMQPUrl string `toml:"amqp-url"`

	// DropUnauthorized will drop samples that do not come from traefik
	// If set to false, it will create an "Unknown" directory in graphite
	DropUnauthorized bool `toml:"drop-unauthorized"`

	CronSchedule string `toml:"cron-schedule"`
	// A list of graphite backend servers
	Outputs []GraphiteOutputConfig `toml:"output"`
}

type GraphiteOutputConfig

type GraphiteOutputConfig struct {
	// Name identifies the graphite backend
	Name string `toml:"name"`

	// Location should be set to the host:port of the backend server
	Location string `toml:"location"`
}

type GraphiteRelay

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

GraphiteRelay is a relay for graphite backends

func (*GraphiteRelay) Name

func (g *GraphiteRelay) Name() string

func (*GraphiteRelay) Run

func (g *GraphiteRelay) Run() error

func (*GraphiteRelay) ServeHTTP

func (g *GraphiteRelay) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*GraphiteRelay) Stop

func (g *GraphiteRelay) Stop() error

type HTTP

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

HTTP is a relay for HTTP influxdb writes

func (*HTTP) Name

func (h *HTTP) Name() string

func (*HTTP) Run

func (h *HTTP) Run() error

func (*HTTP) ServeHTTP

func (h *HTTP) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*HTTP) Stop

func (h *HTTP) Stop() error

type HTTPConfig

type HTTPConfig struct {
	// Name identifies the HTTP relay
	Name string `toml:"name"`

	// Addr should be set to the desired listening host:port
	Addr string `toml:"bind-addr"`

	// Set certificate in order to handle HTTPS requests
	SSLCombinedPem string `toml:"ssl-combined-pem"`

	// Default retention policy to set for forwarded requests
	DefaultRetentionPolicy string `toml:"default-retention-policy"`

	// EnableMetering toggles metering stats to Rabbitmq. You have to setup AMQPUrl for this
	EnableMetering bool `toml:"enable-metering"`

	// AMQPUrl will be used to connect to Rabbitmq (amqp://guest:guest@127.0.0.1:5672/)
	AMQPUrl string `toml:"amqp-url"`

	// DropUnauthorized will drop samples that do not come from traefik
	// If set to false, it will create an "Unknown" directory in graphite
	DropUnauthorized bool `toml:"drop-unauthorized"`

	CronSchedule string `toml:"cron-schedule"`

	// Max allowed number of datapoints per request (0 = Accept all)
	MaxDatapointsPerRequest int `toml:"max-datapoints-per-request"`

	// Split request per number of datapoints (0 = Don't split)
	SplitRequestPerDatapoints int `toml:"split-request-per-datapoints"`

	// Send successful response to telegraf regardless the outcome
	ItsAllGoodMan bool `toml:"its-all-good-man"`

	// Outputs is a list of backed servers where writes will be forwarded
	Outputs []HTTPOutputConfig `toml:"output"`
}

type HTTPOutputConfig

type HTTPOutputConfig struct {
	// Name of the backend server
	Name string `toml:"name"`

	// Location should be set to the URL of the backend server's write endpoint
	Location string `toml:"location"`

	// Type of the backend server e.g. influxdb, graphite, etc.
	BackendType string `toml:"type"`

	// Timeout sets a per-backend timeout for write requests. (Default 10s)
	// The format used is the same seen in time.ParseDuration
	Timeout string `toml:"timeout"`

	// Buffer failed writes up to maximum count. (Default 0, retry/buffering disabled)
	BufferSizeMB int `toml:"buffer-size-mb"`

	// Maximum batch size in KB (Default 512)
	MaxBatchKB int `toml:"max-batch-kb"`

	// Maximum delay between retry attempts.
	// The format used is the same seen in time.ParseDuration (Default 10s)
	MaxDelayInterval string `toml:"max-delay-interval"`

	// Skip TLS verification in order to use self signed certificate.
	// WARNING: It's insecure. Use it only for developing and don't use in production.
	SkipTLSVerification bool `toml:"skip-tls-verification"`
}

type M added in v0.5.2

type M map[string]interface{}

type Operation

type Operation func() error

type Relay

type Relay interface {
	Name() string
	Run() error
	Stop() error
}

func NewBeringei

func NewBeringei(cfg BeringeiConfig) (Relay, error)

func NewGraphiteRelay

func NewGraphiteRelay(cfg GraphiteConfig) (Relay, error)

func NewHTTP

func NewHTTP(cfg HTTPConfig) (Relay, error)

func NewUDP

func NewUDP(config UDPConfig) (Relay, error)

type Service

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

func New

func New(config Config) (*Service, error)

func (*Service) Run

func (s *Service) Run()

func (*Service) Stop

func (s *Service) Stop()

type UDP

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

UDP is a relay for UDP influxdb writes

func (*UDP) Name

func (u *UDP) Name() string

func (*UDP) Run

func (u *UDP) Run() error

func (*UDP) Stop

func (u *UDP) Stop() error

type UDPConfig

type UDPConfig struct {
	// Name identifies the UDP relay
	Name string `toml:"name"`

	// Addr is where the UDP relay will listen for packets
	Addr string `toml:"bind-addr"`

	// Precision sets the precision of the timestamps (input and output)
	Precision string `toml:"precision"`

	// ReadBuffer sets the socket buffer for incoming connections
	ReadBuffer int `toml:"read-buffer"`

	// Outputs is a list of backend servers where writes will be forwarded
	Outputs []UDPOutputConfig `toml:"output"`
}

type UDPOutputConfig

type UDPOutputConfig struct {
	// Name identifies the UDP backend
	Name string `toml:"name"`

	// Location should be set to the host:port of the backend server
	Location string `toml:"location"`

	// MTU sets the maximum output payload size, default is 1024
	MTU int `toml:"mtu"`
}

Jump to

Keyboard shortcuts

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