cwlogs

package module
v0.99.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateRetentionValue added in v0.78.0

func ValidateRetentionValue(input int64) error

Added function to check if value is an accepted number of log retention days

func ValidateTagsInput added in v0.78.0

func ValidateTagsInput(input map[string]*string) error

Check if the tags input is valid

Types

type ByTimestamp

type ByTimestamp []*cloudwatchlogs.InputLogEvent

func (ByTimestamp) Len

func (inputLogEvents ByTimestamp) Len() int

func (ByTimestamp) Less

func (inputLogEvents ByTimestamp) Less(i, j int) bool

func (ByTimestamp) Swap

func (inputLogEvents ByTimestamp) Swap(i, j int)

type Client

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

Possible exceptions are combination of common errors (https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/CommonErrors.html) and API specific erros (e.g. https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutLogEvents.html#API_PutLogEvents_Errors)

func NewClient

func NewClient(logger *zap.Logger, awsConfig *aws.Config, buildInfo component.BuildInfo, logGroupName string, logRetention int64, tags map[string]*string, sess *session.Session, componentName string) *Client

NewClient create Client

func (*Client) CreateStream

func (client *Client) CreateStream(logGroup, streamName *string) error

Prepare the readiness for the log group and log stream.

func (*Client) PutLogEvents

func (client *Client) PutLogEvents(input *cloudwatchlogs.PutLogEventsInput, retryCnt int) error

PutLogEvents mainly handles different possible error could be returned from server side, and retries them if necessary.

type Event

type Event struct {
	InputLogEvent *cloudwatchlogs.InputLogEvent
	// The time which log generated.
	GeneratedTime time.Time
	// Identify what is the stream of destination of this event
	StreamKey
}

Event struct to present a log event.

func NewEvent

func NewEvent(timestampMs int64, message string) *Event

NewEvent creates a new log event logType will be propagated to LogEventBatch and used by logPusher to determine which client to call PutLogEvent

func (*Event) Validate

func (logEvent *Event) Validate(logger *zap.Logger) error

type LogStreamManager added in v0.88.0

type LogStreamManager interface {
	// Initialize a stream so that it can receive logs
	// This will make sure that the stream exists and if it does not exist,
	// It will create one. Implementations of this method MUST be safe for concurrent use.
	InitStream(streamKey StreamKey) error
}

Manages the creation of streams

func NewLogStreamManager added in v0.88.0

func NewLogStreamManager(svcStructuredLog Client) LogStreamManager

type MultiStreamPusherFactory added in v0.88.0

type MultiStreamPusherFactory interface {
	CreateMultiStreamPusher() Pusher
}

Factory for a Pusher that has capability of sending events to multiple log streams

func NewMultiStreamPusherFactory added in v0.88.0

func NewMultiStreamPusherFactory(logStreamManager LogStreamManager, client Client, logger *zap.Logger) MultiStreamPusherFactory

Creates a new MultiStreamPusherFactory

type Pusher

type Pusher interface {
	AddLogEntry(logEvent *Event) error
	ForceFlush() error
}

Pusher is created by log group and log stream

func NewPusher

func NewPusher(streamKey StreamKey, retryCnt int,
	svcStructuredLog Client, logger *zap.Logger) Pusher

NewPusher creates a logPusher instance

type StreamKey added in v0.88.0

type StreamKey struct {
	LogGroupName  string
	LogStreamName string
}

Uniquely identify a cloudwatch logs stream

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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