Skip to content

Nordstrom/logrus-kafka-rest-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logrus-kafka-rest-proxy

A Kafka REST Proxy hook for Logrus

Example

A simple, synchronous example

import (
	"github.com/Nordstrom/logrus-kafka-rest-proxy"
	"github.com/sirupsen/logrus"
)

func main() {
	hook, _ := logrest.NewHook("http://localhost:8082", "hello-logs", &logrest.Options{})

	logger := logrus.New()
	logger.Hooks.Add(hook)

	logger.Info("Hello world")
}

An asynchronous example with all the fixings

import (
	"github.com/Nordstrom/logrus-kafka-rest-proxy"
	"github.com/sirupsen/logrus"
)

func main() {
	hook, _ := logrest.NewHook("https://kafka.example.com", "hello-logs", &logrest.Options{
		Async: &logrest.AsyncOptions{
			QueueTimeout: 30 * time.Second,
			RecordLength: 10,
		},
		Client: &logrest.ClientOptions{
			Headers: map[string]string{
				"X-API-Key": "my-blue-suede-shoes",
			},
			Timeout: 10 * time.Second,
			TLSConfig: &tls.Config{
				...
			},
		},
		Fields: &logrest.FieldOptions{
			FieldRenameMap: map[string]string{
				"msg":  "message",
				"time": "timestamp",
			},
			AdditionalFields: map[string]string{
				"env":  "test",
				"host": os.Getenv("HOSTNAME"),
			},
		},
	})

	logger := logrus.New()
	logger.Hooks.Add(hook)

	logger.Info("Hello world")
	hook.Flush()
}

About

A Kafka REST Proxy hook for Logrus

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages