Skip to content

Acklio/fluxrus

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

fluxrus

logrus hook for InfluxDB

usage

###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()
}

Details

###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:

  1. WithBatchInterval(int): flush the buffer at the given interval in seconds. (default is 5s)
  2. WithBatchSize(int): Max size of the buffer. The buffer gets flushed to the db if this threshold is reached. (default is 200)
  3. WithPrecision(string): Sets the timestamp precision. (default is ns)
  4. WithTags([]string): Use some logrus fields as influxdb tags instead of influxdb fields.
  5. WithClient(influx.Client): A custom influxdb client.

Message Field

We will insert your message into InfluxDB with the field message.

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%