lib

package
v0.0.0-...-400c8b8 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxEventsPerCall is the maximum number events from a filter call
	MaxEventsPerCall = 10000
)
View Source
const (
	ShortTimeFormat = "01-02 15:04:05" // ShortTimeFormat is a short format for printing timestamps

)

These are additional predefined layouts for use in Time.Format and Time.Parse with --since and --until parameters for `cwlogs fetch`

Variables

View Source
var (
	Red     = color.New(color.FgRed).SprintFunc()
	Green   = color.New(color.FgGreen).SprintFunc()
	Yellow  = color.New(color.FgYellow).SprintFunc()
	Blue    = color.New(color.FgBlue).SprintFunc()
	Magenta = color.New(color.FgMagenta).SprintFunc()
	Cyan    = color.New(color.FgCyan).SprintFunc()
	White   = color.New(color.FgWhite).SprintFunc()
)

These color functions are used by output templates to control text color

View Source
var (
	// MaxStreams is the maximum number of streams you can give to a filter call
	MaxStreams = 100
)

Functions

func GetTime

func GetTime(value string, reference time.Time) (time.Time, error)

GetTime tries to parse given string as golang duration, then RFC3339 time and finally as a Unix timestamp. If any of these were successful, it returns a time.Time object. In case of duration input, the returned Time is computed as the given reference time minus the amount of the duration.

func ParseAWSTimestamp

func ParseAWSTimestamp(i *int64) time.Time

ParseAWSTimestamp takes the time stamp format given by AWS and returns an equivalent time.Time value

func SetMaxStreams

func SetMaxStreams(max int)

SetMaxStreams sets the maximum number of streams for describe/filter calls

func Unique

func Unique(args ...string) string

Unique takes a string (or series of strings) and colors that string uniquely based on the string contents. Calling this function with the same string input should always return the same color.

Types

type CloudwatchLogsReader

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

CloudwatchLogsReader is responsible for fetching logs for a particular log group

func NewCloudwatchLogsReader

func NewCloudwatchLogsReader(group string, streamPrefix string, start time.Time, end time.Time) (*CloudwatchLogsReader, error)

NewCloudwatchLogsReader takes a group and optionally a stream prefix, start and end time, and returns a reader for any logs that match those parameters.

func (*CloudwatchLogsReader) Error

func (c *CloudwatchLogsReader) Error() error

Error returns an error if one occurred while streaming events.

func (*CloudwatchLogsReader) GetGroup

GetGroup returns a selected group given a group name

func (*CloudwatchLogsReader) ListGroups

func (c *CloudwatchLogsReader) ListGroups(ctx context.Context) ([]types.LogGroup, error)

ListGroups returns a list of possible groups given a group name

func (*CloudwatchLogsReader) ListStreams

func (c *CloudwatchLogsReader) ListStreams(ctx context.Context) ([]types.LogStream, error)

ListStreams returns any log streams that match the params given in the reader's constructor. Will return at most `MaxStreams` streams

func (*CloudwatchLogsReader) StreamEvents

func (c *CloudwatchLogsReader) StreamEvents(ctx context.Context, follow bool) <-chan Event

StreamEvents returns a channel where you can read events matching the params given in the readers constructor. The channel will be closed once all events are read or an error occurs. You can check for errors after the channel is closed by calling Error()

type Event

type Event struct {
	Event        map[string]interface{}
	Stream       string
	Group        string
	ID           string
	IngestTime   time.Time
	CreationTime time.Time
}

Event represents a log event

func NewEvent

func NewEvent(cwEvent types.FilteredLogEvent, group string) Event

NewEvent takes a cloudwatch log event and returns an Event

func (Event) PrettyPrint

func (e Event) PrettyPrint() string

PrettyPrint returns a formatted json from the full event

func (Event) TimeShort

func (e Event) TimeShort() string

TimeShort gives the timestamp of an event in a readable format

Jump to

Keyboard shortcuts

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