Documentation ¶
Index ¶
- Constants
- Variables
- func GetTime(value string, reference time.Time) (time.Time, error)
- func ParseAWSTimestamp(i *int64) time.Time
- func SetMaxStreams(max int)
- func Unique(args ...string) string
- type CloudwatchLogsReader
- func (c *CloudwatchLogsReader) Error() error
- func (c *CloudwatchLogsReader) GetGroup(ctx context.Context) (types.LogGroup, error)
- func (c *CloudwatchLogsReader) ListGroups(ctx context.Context) ([]types.LogGroup, error)
- func (c *CloudwatchLogsReader) ListStreams(ctx context.Context) ([]types.LogStream, error)
- func (c *CloudwatchLogsReader) StreamEvents(ctx context.Context, follow bool) <-chan Event
- type Event
Constants ¶
const (
// MaxEventsPerCall is the maximum number events from a filter call
MaxEventsPerCall = 10000
)
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 ¶
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
var (
// MaxStreams is the maximum number of streams you can give to a filter call
MaxStreams = 100
)
Functions ¶
func GetTime ¶
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 ¶
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
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) ListGroups ¶
ListGroups returns a list of possible groups given a group name
func (*CloudwatchLogsReader) ListStreams ¶
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 ¶
PrettyPrint returns a formatted json from the full event