LinDB on GitHub
  1. Developer Guide
  2. Insert data

High Performance Writing

The Client Libraries provide user-friendly and high preformance SDKs for a growing number of languages.

Examples

Go client library docs and repo.

package main

import (
	"context"
	"fmt"
	"time"

	lindb "github.com/lindb/client_go"
	"github.com/lindb/client_go/api"
)

func main() {
	// create write client with options
	cli := lindb.NewClientWithOptions(
		"http://localhost:9000",
		lindb.DefaultOptions().SetBatchSize(200).
			SetReqTimeout(60).
			SetRetryBufferLimit(100).
			SetMaxRetries(3),
	)
	// get write client
	w := cli.Write("_internal")
	// get error chan
	errCh := w.Errors()
	go func() {
		for err := range errCh {
			fmt.Printf("got err:%s\n", err)
		}
	}()

	// write some metric data
	for i := 0; i < 10; i++ {
		// write cpu data
		w.AddPoint(context.TODO(), api.NewPoint("cpu").
			AddTag("host", "host1").
			AddField(api.NewSum("load", 10.0)).
			AddField(api.NewLast("usage", 24.0)))
		// write memory data
		w.AddPoint(context.TODO(), api.NewPoint("memory").
			AddTag("host", "host1").
			AddField(api.NewLast("used", 10.0)).
			AddField(api.NewLast("total", 24.0)))
	}

	// close write client
	w.Close()
}

HTTP REST API

InfluxDB Line Protocol

Example request:

For more information about InfluxDB line protocol.

Terminal
curl -XPOST --header "Content-Type: application/influx" http://localhost:9000/api/v1/write?db=_internal --data-binary 'host.cpu,host=192.169.0.1 value=12'