Documentation ¶
Index ¶
- Constants
- Variables
- func DropPolicy(msg *Message, ch chan *Message)
- type CompressType
- type Config
- type DefaultThrottlePolicy
- type FireMessageFunc
- type Hook
- type MergeFields
- type Message
- type Priority
- type Reader
- type Stack
- type TCPWriter
- type ThrottlePolicy
- type ThrottlePolicyConfig
- type UDPWriter
- type Writer
Constants ¶
const (
ChunkSize = 8154
)
Used to control GELF chunking. Should be less than (MTU - len(UDP header)).
TODO: generate dynamically using Path MTU Discovery?
Variables ¶
var BufSize uint = 16384
Set graylog.BufSize = <value> _before_ calling NewHook Once the buffer is full, logging will start blocking, waiting for slots to be available in the queue.
Functions ¶
func DropPolicy ¶
DropPolicy will drop the message if the channel is full
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 )
type Config ¶
type Config struct { Addr string Protocol string Hostname string Facility string TLSConfig *tls.Config Merge func(...map[string]interface{}) map[string]interface{} ThrottlePolicy *ThrottlePolicyConfig }
Config is the required configuration for creating a Graylog hook
type DefaultThrottlePolicy ¶
type DefaultThrottlePolicy struct {
// contains filtered or unexported fields
}
func (*DefaultThrottlePolicy) Flush ¶
func (d *DefaultThrottlePolicy) Flush()
func (*DefaultThrottlePolicy) HandleTrailingMessage ¶
func (d *DefaultThrottlePolicy) HandleTrailingMessage(m Message)
func (*DefaultThrottlePolicy) Init ¶
func (d *DefaultThrottlePolicy) Init(hook *Hook)
func (*DefaultThrottlePolicy) PendingTrailingMessages ¶
func (d *DefaultThrottlePolicy) PendingTrailingMessages() bool
type FireMessageFunc ¶
type Hook ¶
type Hook struct { Facility string Hostname string // Extra fields to send to Graylog for each log entry. Extra map[string]interface{} // Minimum logging level to send to Graylog. // Must be set before adding to logrus logger. // Default is logrus.InfoLevel. Threshold logrus.Level Pid int // contains filtered or unexported fields }
Hook to send logs to a logging service compatible with the Graylog API and the GELF format.
func (*Hook) Fire ¶
Fire is called when a log event is fired. We assume the entry will be altered by another hook, otherwise we might logging something wrong to Graylog
func (*Hook) FireMessage ¶
func (*Hook) IsThrottled ¶
type MergeFields ¶
MergeFields defines a function to merge fields. It used for example to define your own field convientions to match with your graylog service.
type Message ¶
type Message struct { Version string `json:"version"` Host string `json:"host"` Short string `json:"short_message"` Full string `json:"full_message,omitempty"` Time float64 `json:"timestamp"` Level int32 `json:"level"` Pid int `json:"_pid,omitempty"` Facility string `json:"_facility,omitempty"` // optional, deprecated, send as additional field File string `json:"_file,omitempty"` // optional, deprecated, send as additional field Line int `json:"_line,omitempty"` // optional, deprecated, send as additional field Prefix string `json:"_prefix,omitempty"` Extra map[string]interface{} `json:"-"` }
Message represents the contents of the GELF message. It is gzipped before sending.
func (*Message) MarshalJSON ¶
func (*Message) UnmarshalJSON ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
func (*Reader) ReadMessage ¶
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
Stack is a basic LIFO stack that resizes as needed.
type TCPWriter ¶
TCPWriter implements io.Writer and is used to send both discret messages to a graylog2 server, or data from a stream-oriented interface (like the functions in log).
func NewTCPWriter ¶
NewTCPWriter returns a new TCP GELF Writer. 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()
func (*TCPWriter) Write ¶
Write writes a given data, converts it to a GELF message and writes it with the current TCP connection
func (*TCPWriter) WriteMessage ¶
WriteMessage writes a GELF message with current TCP connection
type ThrottlePolicy ¶
type ThrottlePolicy interface { Init(hook *Hook) HandleTrailingMessage(m Message) PendingTrailingMessages() bool Flush() }
func NewDefaultThrottlePolicy ¶
func NewDefaultThrottlePolicy() ThrottlePolicy
type ThrottlePolicyConfig ¶
type ThrottlePolicyConfig struct { Amount int Period time.Duration Policy ThrottlePolicy }
type UDPWriter ¶
type UDPWriter struct { Facility string // defaults to current process name CompressionLevel int // one of the consts from compress/flate CompressionType CompressType // 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 NewUDPWriter ¶
NewUDPWriter returns a new GELF Writer. 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()
func (*UDPWriter) Write ¶
Write encodes the given string in a GELF message and sends it to the server specified in New().
func (*UDPWriter) WriteMessage ¶
WriteMessage sends the specified message to the GELF server specified in the call to New(). It assumes all the fields are filled out appropriately. In general, clients will want to use Write, rather than WriteMessage.