Documentation ¶
Index ¶
Constants ¶
const (
DefaultChunkSize = 1420
)
Used to control GELF chunking. Should be less than (MTU - len(UDP header)).
TODO: generate dynamically using Path MTU Discovery?
const ModuleName = "gelf"
ModuleName is the name used in config file
Variables ¶
var ( ErrNoValidHosts = errutil.NewFactory("no valid Hosts found") ErrInvalidHost = errutil.NewFactory("Some host are invalid. Should respect the format: hostname:port") ErrorCreateClientFailed1 = errutil.NewFactory("create gelf client failed: %q") )
errors
Functions ¶
Types ¶
type CompressType ¶
type CompressType int
What compression type the writer should use when sending messages to the graylog2 server
const ( CompressGzip CompressType = iota CompressZlib NoCompress )
type GELFConfig ¶
type GELFConfig struct { Host string ChunkSize int // Default Value: 1420 CompressionLevel int // Default: 1 CompressionType CompressType // Default: Gzip }
type GELFWriter ¶
type GELFWriter interface { WriteCustomMessage(ctx context.Context, m *Message) error WriteMessage(ctx context.Context, sm *SimpleMessage) error }
func NewWriter ¶
func NewWriter(config GELFConfig) (GELFWriter, error)
NewWriter returns a new GELFWriter. This writer can be used to send the output of the standard Go log functions to a central GELF server by passing it to log.SetOutput()
type HTTPWriter ¶
type HTTPWriter struct {
// contains filtered or unexported fields
}
HTTPWriter implements the GELFWriter interface, and cannot be used as an io.Writer
func (HTTPWriter) WriteCustomMessage ¶
func (h HTTPWriter) WriteCustomMessage(ctx context.Context, m *Message) error
func (HTTPWriter) WriteMessage ¶
func (h HTTPWriter) WriteMessage(ctx context.Context, sm *SimpleMessage) error
WriteMessage allow to send messsage to gelf Server It only request basic fields and will handle conversion & co
type Message ¶
type Message struct { Extra map[string]any `json:"-"` Full string `json:"full_message"` Host string `json:"host"` Level int32 `json:"level"` Short string `json:"short_message"` Timestamp int64 `json:"timestamp"` Version string `json:"version"` }
Message represents the contents of the GELF message. It is gzipped before sending. https://docs.graylog.org/docs/gelf
func (*Message) MarshalJSON ¶
type OutputConfig ¶
type OutputConfig struct { config.OutputConfig ChunkSize int `json:"chunk_size" yaml:"chunk_size"` CompressionLevel int `json:"compression_level" yaml:"compression_level"` CompressionType int `json:"compression_type" yaml:"compression_type"` Hosts []string `json:"hosts" yaml:"hosts"` // List of Gelf Host servers, format: ip:port RetryInterval uint `json:"retry_interval" yaml:"retry_interval"` // seconds before a new retry in case on error MaxQueueSize int `json:"max_queue_size" yaml:"max_queue_size"` // max size of queue before deleting events (-1=no limit, 0=disable) // contains filtered or unexported fields }
OutputConfig holds the configuration json fields and internal objects
func DefaultOutputConfig ¶
func DefaultOutputConfig() OutputConfig
DefaultOutputConfig returns an OutputConfig struct with default values
func (*OutputConfig) OutputEvent ¶
OutputEvent handle message from the queue
type SimpleMessage ¶
type UDPWriter ¶
type UDPWriter struct {
// contains filtered or unexported fields
}
UDPWriter implements io.Writer and is used to send both discrete messages to a graylog2 server, or data from a stream-oriented interface (like the functions in log).
func (*UDPWriter) WriteCustomMessage ¶
WriteCustomMessage sends the specified message to the GELF server specified in the call to NewWriter(). It assumes all the fields are filled out appropriately. In general, clients will want to use Write, rather than WriteMessage.
func (*UDPWriter) WriteMessage ¶
func (w *UDPWriter) WriteMessage(ctx context.Context, sm *SimpleMessage) error
WriteMessage allow to send messsage to gelf Server It only request basic fields and will handle conversion & co