fluent

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2021 License: Apache-2.0 Imports: 17 Imported by: 328

Documentation

Index

Constants

View Source
const Version = "1.9.0"

Variables

This section is empty.

Functions

func NewErrUnknownNetwork added in v1.5.0

func NewErrUnknownNetwork(network string) error

Types

type AckResp added in v1.4.0

type AckResp struct {
	Ack string `json:"ack" msg:"ack"`
}

func (*AckResp) DecodeMsg added in v1.4.0

func (z *AckResp) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (AckResp) EncodeMsg added in v1.4.0

func (z AckResp) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (AckResp) MarshalMsg added in v1.4.0

func (z AckResp) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (AckResp) Msgsize added in v1.4.0

func (z AckResp) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*AckResp) UnmarshalMsg added in v1.4.0

func (z *AckResp) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Config

type Config struct {
	FluentPort          int           `json:"fluent_port"`
	FluentHost          string        `json:"fluent_host"`
	FluentNetwork       string        `json:"fluent_network"`
	FluentSocketPath    string        `json:"fluent_socket_path"`
	Timeout             time.Duration `json:"timeout"`
	WriteTimeout        time.Duration `json:"write_timeout"`
	BufferLimit         int           `json:"buffer_limit"`
	RetryWait           int           `json:"retry_wait"`
	MaxRetry            int           `json:"max_retry"`
	MaxRetryWait        int           `json:"max_retry_wait"`
	TagPrefix           string        `json:"tag_prefix"`
	Async               bool          `json:"async"`
	ForceStopAsyncSend  bool          `json:"force_stop_async_send"`
	AsyncResultCallback func(data []byte, err error)
	// Deprecated: Use Async instead
	AsyncConnect  bool `json:"async_connect"`
	MarshalAsJSON bool `json:"marshal_as_json"`

	// AsyncReconnectInterval defines the interval (ms) at which the connection
	// to the fluentd-address is re-established. This option is useful if the address
	// may resolve to one or more IP addresses, e.g. a Consul service address.
	AsyncReconnectInterval int `json:"async_reconnect_interval"`

	// Sub-second precision timestamps are only possible for those using fluentd
	// v0.14+ and serializing their messages with msgpack.
	SubSecondPrecision bool `json:"sub_second_precision"`

	// RequestAck sends the chunk option with a unique ID. The server will
	// respond with an acknowledgement. This option improves the reliability
	// of the message transmission.
	RequestAck bool `json:"request_ack"`

	// Flag to skip verifying insecure certs on TLS connections
	TlsInsecureSkipVerify bool `json: "tls_insecure_skip_verify"`
}

type Entry added in v1.0.0

type Entry struct {
	Time   int64       `msg:"time"`
	Record interface{} `msg:"record"`
}

func (*Entry) DecodeMsg added in v1.0.0

func (z *Entry) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (Entry) EncodeMsg added in v1.0.0

func (z Entry) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (Entry) MarshalMsg added in v1.0.0

func (z Entry) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (Entry) Msgsize added in v1.0.0

func (z Entry) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Entry) UnmarshalMsg added in v1.0.0

func (z *Entry) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type ErrUnknownNetwork added in v1.5.0

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

func (*ErrUnknownNetwork) Error added in v1.5.0

func (e *ErrUnknownNetwork) Error() string

type EventTime added in v1.3.0

type EventTime time.Time

EventTime is an extension to the serialized time value. It builds in support for sub-second (nanosecond) precision in serialized timestamps.

You can find the full specification for the msgpack message payload here: https://github.com/fluent/fluentd/wiki/Forward-Protocol-Specification-v1.

You can find more information on msgpack extension types here: https://github.com/tinylib/msgp/wiki/Using-Extensions.

func (*EventTime) ExtensionType added in v1.3.0

func (t *EventTime) ExtensionType() int8

func (*EventTime) Len added in v1.3.0

func (t *EventTime) Len() int

func (*EventTime) MarshalBinaryTo added in v1.3.0

func (t *EventTime) MarshalBinaryTo(b []byte) error

func (*EventTime) UnmarshalBinary added in v1.3.0

func (t *EventTime) UnmarshalBinary(b []byte) error

Although decoding messages is not officially supported by this library, UnmarshalBinary is implemented for testing and general completeness.

type Fluent

type Fluent struct {
	Config
	// contains filtered or unexported fields
}

func New

func New(config Config) (*Fluent, error)

New creates a new Logger.

func (*Fluent) Close

func (f *Fluent) Close() (err error)

Close closes the connection, waiting for pending logs to be sent. If the client is running in async mode, the run() goroutine exits before Close() returns.

func (*Fluent) EncodeAndPostData added in v1.0.0

func (f *Fluent) EncodeAndPostData(tag string, tm time.Time, message interface{}) error

func (*Fluent) EncodeData added in v1.0.0

func (f *Fluent) EncodeData(tag string, tm time.Time, message interface{}) (msg *msgToSend, err error)

func (*Fluent) Post

func (f *Fluent) Post(tag string, message interface{}) error

Post writes the output for a logging event.

Examples:

// send map[string]
mapStringData := map[string]string{
	"foo":  "bar",
}
f.Post("tag_name", mapStringData)

// send message with specified time
mapStringData := map[string]string{
	"foo":  "bar",
}
tm := time.Now()
f.PostWithTime("tag_name", tm, mapStringData)

// send struct
structData := struct {
		Name string `msg:"name"`
} {
		"john smith",
}
f.Post("tag_name", structData)

func (*Fluent) PostRawData deprecated added in v1.0.0

func (f *Fluent) PostRawData(msg *msgToSend)

Deprecated: Use EncodeAndPostData instead

func (*Fluent) PostWithTime added in v0.4.3

func (f *Fluent) PostWithTime(tag string, tm time.Time, message interface{}) error

type Forward added in v1.0.0

type Forward struct {
	Tag     string  `msg:"tag"`
	Entries []Entry `msg:"entries"`
	Option  map[string]string
}

func (*Forward) DecodeMsg added in v1.0.0

func (z *Forward) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Forward) EncodeMsg added in v1.0.0

func (z *Forward) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Forward) MarshalMsg added in v1.0.0

func (z *Forward) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Forward) Msgsize added in v1.0.0

func (z *Forward) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Forward) UnmarshalMsg added in v1.0.0

func (z *Forward) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Message added in v1.0.0

type Message struct {
	Tag    string      `msg:"tag"`
	Time   int64       `msg:"time"`
	Record interface{} `msg:"record"`
	Option map[string]string
}

func (*Message) DecodeMsg added in v1.0.0

func (z *Message) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Message) EncodeMsg added in v1.0.0

func (z *Message) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Message) MarshalMsg added in v1.0.0

func (z *Message) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Message) Msgsize added in v1.0.0

func (z *Message) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Message) UnmarshalMsg added in v1.0.0

func (z *Message) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type MessageChunk added in v1.2.0

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

For sending forward protocol adopted JSON

func (*MessageChunk) MarshalJSON added in v1.2.0

func (chunk *MessageChunk) MarshalJSON() ([]byte, error)

Golang default marshaler does not support ["value", "value2", {"key":"value"}] style marshaling. So, it should write JSON marshaler by hand.

type MessageExt added in v1.3.0

type MessageExt struct {
	Tag    string      `msg:"tag"`
	Time   EventTime   `msg:"time,extension"`
	Record interface{} `msg:"record"`
	Option map[string]string
}

func (*MessageExt) DecodeMsg added in v1.3.0

func (z *MessageExt) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*MessageExt) EncodeMsg added in v1.3.0

func (z *MessageExt) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*MessageExt) MarshalMsg added in v1.3.0

func (z *MessageExt) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*MessageExt) Msgsize added in v1.3.0

func (z *MessageExt) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*MessageExt) UnmarshalMsg added in v1.3.0

func (z *MessageExt) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type TestMessage added in v1.3.0

type TestMessage struct {
	Foo  string `msg:"foo" json:"foo,omitempty"`
	Hoge string `msg:"hoge" json:"hoge,omitempty"`
}

func (*TestMessage) DecodeMsg added in v1.3.0

func (z *TestMessage) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (TestMessage) EncodeMsg added in v1.3.0

func (z TestMessage) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (TestMessage) MarshalMsg added in v1.3.0

func (z TestMessage) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (TestMessage) Msgsize added in v1.3.0

func (z TestMessage) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*TestMessage) UnmarshalMsg added in v1.3.0

func (z *TestMessage) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

Jump to

Keyboard shortcuts

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