###Installation
go get github.com/HeavyHorst/fluxrus
###Example
import (
"github.com/HeavyHorst/fluxrus"
"github.com/Sirupsen/logrus"
)
func main() {
log := logrus.New()
hook, err := fluxrus.New("http://influxdbhost:8086", "mydb", "my_measurement", fluxrus.WithBatchSize(2000), fluxrus.WithTags([]string{"mytag"}))
if err == nil {
log.Hooks.Add(hook)
}
defer hook.Close()
}
###Buffer All log messages are buffered by default to increase the performance. You need to run hook.Close() on program exit to get sure that all messages are written to the database.
###Configuration The constructor takes some optional configuration options:
- WithBatchInterval(int): flush the buffer at the given interval in seconds. (default is 5s)
- WithBatchSize(int): Max size of the buffer. The buffer gets flushed to the db if this threshold is reached. (default is 200)
- WithPrecision(string): Sets the timestamp precision. (default is ns)
- WithTags([]string): Use some logrus fields as influxdb tags instead of influxdb fields.
- WithClient(influx.Client): A custom influxdb client.
We will insert your message into InfluxDB with the field message.