datadog

package module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 24, 2020 License: Apache-2.0 Imports: 8 Imported by: 1

README

logrus-datadog-hook

Shipping log entries from logrus to Datadog log API HTTP endpoint

Example

    hostName, _ := os.Hostname()
    // Sending log in JSON, batch log every 5 sec and when failure, retry up to 3 times
    hook := NewHook(host, apiKey, 5*time.Second, 3, logrus.TraceLevel, &logrus.JSONFormatter{}, Options{Hostname: hostName})
    l := logrus.New()
    l.Hooks.Add(hook)
    l.WithField("from", "unitest").Infof("TestSendingJSON - %d", i)

Documentation

Index

Constants

View Source
const (
	// DatadogUSHost - Host For Datadog US
	DatadogUSHost = "http-intake.logs.datadoghq.com"
	// DatadogEUHost - Host For Datadog EU
	DatadogEUHost = "http-intake.logs.datadoghq.eu"
)

Variables

View Source
var (
	// Debug - print out debug log if true
	Debug = false
)

Functions

This section is empty.

Types

type Hook

type Hook struct {
	// contains filtered or unexported fields
}

Hook is the struct holding connect information to Datadog backend

func NewHook

func NewHook(
	host string,
	apiKey string,
	batchTimeout time.Duration,
	maxRetry int,
	minLevel logrus.Level,
	formatter logrus.Formatter,
	options Options,
) *Hook

NewHook - create hook with input

func (*Hook) Fire

func (h *Hook) Fire(entry *logrus.Entry) error

Fire - implement Hook interface fire the entry

func (*Hook) Levels

func (h *Hook) Levels() []logrus.Level

Levels - implement Hook interface supporting all levels

type Options added in v0.0.3

type Options struct {
	Source   string
	Service  string
	Hostname string
	Tags     []string
}

Options define the options for Datadog log stream

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL