Back to godoc.org
bosun.org / collect

Package collect

v0.0.0-...-8a7cd2d
Latest Go to latest

The latest major version is .

Published: Jun 18, 2020 | License: MIT | Module: bosun.org

Overview

Package collect provides functions for sending data to OpenTSDB.

The "collect" namespace is used (i.e., <root>.collect) to collect program and queue metrics.

Index

Constants

const RedisCountersKey = "scollectorCounters"

Variables

var (
	// Freq is how often metrics are sent to OpenTSDB.
	Freq = time.Second * 15

	// MaxQueueLen is the maximum size of the queue, above which incoming data will
	// be discarded. Defaults to about 150MB.
	MaxQueueLen = 200000

	// BatchSize is the maximum length of data points sent at once to OpenTSDB.
	BatchSize = 500

	// Debug enables debug logging.
	Debug = false

	// Print prints all datapoints to stdout instead of sending them.
	Print = false

	// DisableDefaultCollectors prevents the scollector self metrics from being
	// generated.
	DisableDefaultCollectors = false

	// Tags is an opentsdb.TagSet used when sending self metrics.
	Tags opentsdb.TagSet

	// Whether or not to use NTLM authentication
	UseNtlm bool = false

	// DefaultClient can be used to override the HTTP client that will be used to make requests.
	DefaultClient *http.Client = http.DefaultClient

	// Authtoken is the token to use to communicate with bosun
	AuthToken string

	//DirectHandler is an http handler to invoke instead of actually making a network request
	DirectHandler http.Handler
)

func Add

func Add(metric string, ts opentsdb.TagSet, inc int64) error

Add takes a metric and increments a counter for that metric. The metric name is appended to the basename specified in the Init function.

func AggregateMeta

func AggregateMeta(metric string, unit metadata.Unit, desc string)

func Flush

func Flush()

Locks the queue and sends all datapoints. Intended to be used as scollector exits.

func Get

func Get(metric string, ts opentsdb.TagSet) int64

func HandleCounterPut

func HandleCounterPut(server string, database int) http.HandlerFunc

func Init

func Init(tsdbhost *url.URL, root string) error

Init sets up the channels and the queue for sending data to OpenTSDB. It also sets up the basename for all metrics.

func InitChan

func InitChan(tsdbhost *url.URL, root string, ch chan *opentsdb.DataPoint) error

InitChan is similar to Init, but uses the given channel instead of creating a new one.

func Put

func Put(metric string, ts opentsdb.TagSet, v interface{}) error

Put is useful for capturing "events" that have a gauge value. Subsequent calls between the sending interval will overwrite previous calls.

func Sample

func Sample(metric string, ts opentsdb.TagSet, v float64) error

func SendDataPoints

func SendDataPoints(dps []*opentsdb.DataPoint, tsdb string) (*http.Response, error)

func Set

func Set(metric string, ts opentsdb.TagSet, f func() interface{}) error

Set registers a callback for the given metric and tags, calling f immediately before queueing data for send.

func StartTimer

func StartTimer(metric string, ts opentsdb.TagSet) func()

StartTimer records the current time, and returns a function you can call to record the end of your action.

Typical usage would be:

done := collect.StartTimer("myMetric", opentsdb.TagSet{})
doMyThing()
done()
Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier