promrus

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2017 License: Apache-2.0 Imports: 2 Imported by: 17

README

promrus

Logrus hook to expose the number of log messages as Prometheus metrics:

log_messages{level="debug"}
log_messages{level="info"}
log_messages{level="warning"}
log_messages{level="error"}

Usage

hook, err := promrus.NewPrometheusHook(appName)
if err != nil {
	log.AddHook(hook)
}

Setup development environment

$ go get github.com/golang/dep/cmd/dep
$ dep ensure

Compile

$ go build

Test

$ go test
DEBU[0000] this is at debug level!                      
INFO[0000] this is at info level!                       
WARN[0000] this is at warning level!                    
ERRO[0000] this is at error level!                      
PASS
ok  	github.com/marccarre/promrus	0.011s

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PrometheusHook

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

PrometheusHook exposes Prometheus counters for each of logrus' log levels.

func NewPrometheusHook

func NewPrometheusHook() (*PrometheusHook, error)

NewPrometheusHook creates a new instance of PrometheusHook which exposes Prometheus counters for various log levels.

func (*PrometheusHook) Fire

func (hook *PrometheusHook) Fire(entry *logrus.Entry) error

Fire increments the appropriate Prometheus counter depending on the entry's log level.

func (*PrometheusHook) Levels

func (hook *PrometheusHook) Levels() []logrus.Level

Levels returns all supported log levels, i.e.: Debug, Info, Warn and Error, as there is no point incrementing a counter just before exiting/panicking.

Jump to

Keyboard shortcuts

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