n10ty / opentsdb-go-push

Client to push opentsdb metrics

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OpenTSDB metrics push GO client

OpenTSDB client helps to send standardized metric to /api/put path.

Client has 2 options to send metrics:

  • Enqueue metrics, send when batchSize collected and flush buffer. Use Push to force send current buffer.
  • Send single Metric immediately.

Important

Do not forger invoke Close on service down, to send unfilled buffer

Usage

Import:

go get github.com/n10ty/opentsdb-go-push

Example:

func main() {
    client := opentsdb.NewClient("http://localhost:4242", opentsdb.WithBatchSize(30), opentsdb.WithAuth("user", "pass"))
	err := client.Enqueue(opentsdb.Metric{
		Timestamp: time.Now().Truncate(time.Minute).Unix(),
		Metric:    "http_response_time",
		Value:     39.3,
		Tags: map[string]string{
			"server": "server1",
		},
	})
	if err != nil {
		//...
	}
	client.Push()
}

About

Client to push opentsdb metrics


Languages

Language:Go 100.0%