gelf

package module
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2021 License: Apache-2.0 Imports: 4 Imported by: 2

README

KrakenD-gelf

Go Report Card

A gelf (Graylog Extended Log Format) Writer for KrakenD loggers.

How to use it

This package just return a gelf writer with the configuration provided via KrakenD ExtraConfig.

You need to add the Writer to the logger writers. This example uses KrakenD-gologging.

Import the package

import "github.com/devopsfaith/krakend-gelf"

Create a new Writer:

gelfWriter, err := gelf.NewWriter(cfg.ExtraConfig)

And add it to the logger:

gologging.NewLogger(cfg.ExtraConfig, gelfWriter...)

Configuration

Add the github_com/devopsfaith/krakend-gelf section to the service extra config.

There's 2 parameters:

  • address (This parameter is required)

    The address (including the port) of your graylog server (or any service that receives gelf inputs).

  • enable_tcp

    By default uses UDP but you can enable TCP by setting this option to true (not recommended, your performance may suffer).

Example:

"extra_config": {
  "github_com/devopsfaith/krakend-gelf": {
    "address": "myGraylogInstance:12201",
    "enable_tcp": false
  }
}

Documentation

Index

Constants

View Source
const Namespace = "github_com/devopsfaith/krakend-gelf"

Namespace is the key to look for extra configuration details

Variables

View Source
var (

	// ErrWrongConfig is the error returned when there is no config under the namespace
	ErrWrongConfig = fmt.Errorf("getting the extra config for the krakend-gelf module")
	// ErrMissingAddr is the error returned when there address param is empty
	ErrMissingAddr = fmt.Errorf("missing addr to send gelf logs")
)

Functions

func ConfigGetter

func ConfigGetter(e config.ExtraConfig) interface{}

ConfigGetter implements the config.ConfigGetter interface

func NewWriter

func NewWriter(cfg config.ExtraConfig) (io.Writer, error)

NewWriter returns an io.Writer to write gelf logs to a server

Types

type Config

type Config struct {
	Addr      string
	EnableTCP bool
}

Config is the custom config struct containing the params for the Writer

Jump to

Keyboard shortcuts

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