cloudwatch

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 5, 2016 License: MIT Imports: 8 Imported by: 1

README

logspout-cloudwatch

Build Status

A Logspout adapter for writing Docker container logs to AWS CloudWatch.

Usage

Route logs from all containers to CloudWatch by starting logspout with the following options:

docker run --name=logspout --hostname=$HOSTNAME \
    -e AWS_REGION=us-west-2 \
    -v /var/run/docker.sock:/tmp/docker.sock
    my-logspout-container cloudwatch://my-log-group

Once started, this container will create a new Log Stream ($HOSTNAME) within the specified Log Group (my-log-group) and begin streaming Docker container logs into CloudWatch.

This example depends on a custom Logspout container (my-logspout-container) built with the logspout-cloudwatch module and an existing CloudWatch Log Group (my-log-group). See gliderlabs/logspout#modules for more information on building custom logspout containers.

Configuration

logspout-cloudwatch accepts a number of environment variables that can be used to customize behavior.

AWS_REGION

Determines the AWS region to which logs will be sent. This option is required.

LOG_LEVEL

Determines the log level used for logspout-cloudwatch logs. This option defaults to INFO, and logspout-cloudwatch will only log startup information, information about failed uploads, and information about rejected events. Set this option to DEBUG for detailed information about each uploaded log batch.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAdapter

func NewAdapter(route *router.Route) (router.LogAdapter, error)

NewAdapter instances a new AWS CloudWatch adapter.

Types

type Adapter

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

Adapter ships logs to AWS CloudWatch.

func (*Adapter) Stream

func (a *Adapter) Stream(logstream chan *router.Message)

Stream passes messages from a logspout message channel to AWS CloudWatch.

type Batcher

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

Batcher buffers messages on a channel until a flush is triggered.

func NewBatcher

func NewBatcher(in <-chan Log, out chan<- []Log, capacity Capacity) *Batcher

NewBatcher creates a Batcher that buffers message from the input channel to the output channel.

func (*Batcher) Length

func (b *Batcher) Length() int

Length returns the current length of the buffer.

func (*Batcher) Start

func (b *Batcher) Start()

Start begins buffering messages from the input channel.

type Capacity

type Capacity struct {
	Size     int
	Length   int
	Duration time.Duration
}

Capacity returns conditions that trigger a Batcher to flush.

type FakeLog

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

func (*FakeLog) Body

func (l *FakeLog) Body() string

func (*FakeLog) Size

func (l *FakeLog) Size() int

func (*FakeLog) Timestamp

func (l *FakeLog) Timestamp() int64

type Log

type Log interface {
	Body() string
	Size() int
	Timestamp() int64
}

type LogMessage

type LogMessage struct {
	*router.Message
}

LogMessage represents a log message to be sent to CloudWatch.

func (*LogMessage) Body

func (l *LogMessage) Body() string

Body returns a string representation of the log.

func (*LogMessage) Size

func (l *LogMessage) Size() int

Size returns the size of the log message in bytes.

func (*LogMessage) Timestamp

func (l *LogMessage) Timestamp() int64

Timestamp returns the number of milliseconds since the epoch.

type LogStream

type LogStream struct {
	Group  *string
	Stream *string
	Token  *string
	// contains filtered or unexported fields
}

LogStream ships logs to AWS CloudWatch.

func NewLogStream

func NewLogStream(group, stream string) (*LogStream, error)

NewLogStream instantiates a Logger.

func (*LogStream) Init

func (s *LogStream) Init() error

Init fetches the sequence token for a stream so logs can be streamed.

func (*LogStream) Log

func (s *LogStream) Log(logs []*cloudwatchlogs.InputLogEvent) error

Log submits a batch of logs to the LogStream.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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