syslog

package
v0.0.0-...-4d4bd85 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const BATCHSIZE = 256 * 1024
View Source
const RFC5424TimeOffsetNum = "2006-01-02T15:04:05.999999-07:00"

Variables

This section is empty.

Functions

func ExponentialDuration

func ExponentialDuration(attempt int) time.Duration

ExponentialDuration returns a duration that grows exponentially with each attempt. It is maxed out at 15 seconds.

func NewHTTPSBatchWriter

func NewHTTPSBatchWriter(
	binding *URLBinding,
	netConf NetworkTimeoutConfig,
	tlsConf *tls.Config,
	egressMetric metrics.Counter,
	c *Converter,
) egress.WriteCloser

func NewHTTPSWriter

func NewHTTPSWriter(
	binding *URLBinding,
	netConf NetworkTimeoutConfig,
	tlsConf *tls.Config,
	egressMetric metrics.Counter,
	c *Converter,
) egress.WriteCloser

func NewRetryWriter

func NewRetryWriter(
	urlBinding *URLBinding,
	retryDuration RetryDuration,
	maxRetries int,
	writer egress.WriteCloser,
) (egress.WriteCloser, error)

func NewTCPWriter

func NewTCPWriter(
	binding *URLBinding,
	netConf NetworkTimeoutConfig,
	egressMetric metrics.Counter,
	c *Converter,
) egress.WriteCloser

NewTCPWriter creates a new TCP syslog writer.

func NewTLSWriter

func NewTLSWriter(
	binding *URLBinding,
	netConf NetworkTimeoutConfig,
	tlsConf *tls.Config,
	egressMetric metrics.Counter,
	syslogConverter *Converter,
) egress.WriteCloser

func NewWriterFactoryErrorf

func NewWriterFactoryErrorf(u *url.URL, format string, a ...any) error

Types

type Binding

type Binding struct {
	AppId        string    `json:"appId,omitempty"`
	Hostname     string    `json:"hostname,omitempty"`
	Drain        Drain     `json:"drain,omitempty"`
	DrainData    DrainData `json:"type,omitempty"`
	OmitMetadata bool
	InternalTls  bool
}

type ConnectorOption

type ConnectorOption func(*SyslogConnector)

ConnectorOption allows a syslog connector to be customized.

func WithLogClient

func WithLogClient(logClient LogClient, sourceIndex string) ConnectorOption

WithLogClient returns a ConnectorOption that will set up logging for any information about a binding.

type Converter

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

func NewConverter

func NewConverter(opts ...ConverterOption) *Converter

func (*Converter) BuildHostname

func (c *Converter) BuildHostname(env *loggregator_v2.Envelope, defaultHostname string) string

func (*Converter) ToRFC5424

func (c *Converter) ToRFC5424(env *loggregator_v2.Envelope, defaultHostname string) ([][]byte, error)

type ConverterOption

type ConverterOption func(*Converter)

func WithoutSyslogMetadata

func WithoutSyslogMetadata() ConverterOption

type Credentials

type Credentials struct {
	Cert string `json:"cert"`
	Key  string `json:"key"`
	CA   string `json:"ca"`
}

type DialFunc

type DialFunc func(addr string) (net.Conn, error)

DialFunc represents a method for creating a connection, either TCP or TLS.

type Drain

type Drain struct {
	Url         string      `json:"url"`
	Credentials Credentials `json:"credentials"`
}

type DrainData

type DrainData int
const (
	LOGS DrainData = iota
	METRICS
	TRACES
	ALL
	LOGS_NO_EVENTS
	LOGS_AND_METRICS
)

type EnvelopeWriter

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

func NewEnvelopeWriter

func NewEnvelopeWriter(drainGetter drainGetter, nextEnvelope nextEnvelope, ingress metrics.Counter, log *log.Logger) *EnvelopeWriter

func (*EnvelopeWriter) Run

func (w *EnvelopeWriter) Run()

type FilteringDrainWriter

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

func NewFilteringDrainWriter

func NewFilteringDrainWriter(binding Binding, writer egress.Writer) (*FilteringDrainWriter, error)

func (*FilteringDrainWriter) Write

type HTTPSBatchWriter

type HTTPSBatchWriter struct {
	HTTPSWriter
	// contains filtered or unexported fields
}

func (*HTTPSBatchWriter) Write

Modified Write function

type HTTPSWriter

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

func (*HTTPSWriter) Close

func (*HTTPSWriter) Close() error

func (*HTTPSWriter) Write

func (w *HTTPSWriter) Write(env *loggregator_v2.Envelope) error

type LogClient

type LogClient interface {
	EmitLog(message string, opts ...loggregator.EmitLogOption)
}

LogClient is used to emit logs.

type NetworkTimeoutConfig

type NetworkTimeoutConfig struct {
	Keepalive    time.Duration
	DialTimeout  time.Duration
	WriteTimeout time.Duration
}

NetworkTimeoutConfig stores various timeout values.

type RetryDuration

type RetryDuration func(attempt int) time.Duration

RetryDuration calculates a duration based on the number of write attempts.

type RetryWriter

type RetryWriter struct {
	Writer egress.WriteCloser //public to allow testing
	// contains filtered or unexported fields
}

RetryWriter wraps a WriteCloser and will retry writes if the first fails.

func (*RetryWriter) Close

func (r *RetryWriter) Close() error

Close delegates to the syslog writer.

func (*RetryWriter) Write

Write will retry writes unitl maxRetries has been reached.

type SyslogConnector

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

SyslogConnector creates the various egress syslog writers.

func NewSyslogConnector

func NewSyslogConnector(
	skipCertVerify bool,
	wg egress.WaitGroup,
	f writerFactory,
	m metricClient,
	opts ...ConnectorOption,
) *SyslogConnector

NewSyslogConnector configures and returns a new SyslogConnector.

func (*SyslogConnector) Connect

func (w *SyslogConnector) Connect(ctx context.Context, b Binding) (egress.Writer, error)

Connect returns an egress writer based on the scheme of the binding drain URL.

type TCPWriter

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

TCPWriter represents a syslog writer that connects over unencrypted TCP. This writer is not meant to be used from multiple goroutines. The same goroutine that calls `.Write()` should be the one that calls `.Close()`.

func (*TCPWriter) Close

func (w *TCPWriter) Close() error

Close tears down any active connections to the drain and prevents reconnect.

func (*TCPWriter) Write

func (w *TCPWriter) Write(env *loggregator_v2.Envelope) error

Write writes an envelope to the syslog drain connection.

type TLSWriter

type TLSWriter struct {
	TCPWriter
}

TLSWriter represents a syslog writer that connects over unencrypted TCP.

type URLBinding

type URLBinding struct {
	Context      context.Context
	AppID        string
	Hostname     string
	OmitMetadata bool
	InternalTls  bool
	URL          *url.URL
	PrivateKey   []byte
	Certificate  []byte
	CA           []byte
}

application is identified by AppID and Hostname. The syslog URL is identified by URL.

func (*URLBinding) Scheme

func (u *URLBinding) Scheme() string

Scheme is a convenience wrapper around the *url.URL Scheme field

type WriterFactory

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

func NewWriterFactory

func NewWriterFactory(internalTlsConfig *tls.Config, externalTlsConfig *tls.Config, netConf NetworkTimeoutConfig, m metricClient) WriterFactory

func (WriterFactory) NewWriter

func (f WriterFactory) NewWriter(ub *URLBinding) (egress.WriteCloser, error)

type WriterFactoryError

type WriterFactoryError struct {
	Message string
	URL     *url.URL
}

func (WriterFactoryError) Error

func (e WriterFactoryError) Error() string

Jump to

Keyboard shortcuts

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