Documentation ¶
Index ¶
Constants ¶
const DEFAULT_DELAY = 4 //seconds
const MAX_BATCH_COUNT = 10000 // messages
Rules for creating Cloudwatch Log batches, from https://goo.gl/TrIN8c
const MAX_BATCH_SIZE = 1048576 // bytes
const MSG_OVERHEAD = 26 // bytes
Variables ¶
This section is empty.
Functions ¶
func NewCloudwatchAdapter ¶
func NewCloudwatchAdapter(route *router.Route) (router.LogAdapter, error)
NewCloudwatchAdapter creates a CloudwatchAdapter for the current region.
Types ¶
type CloudwatchAdapter ¶
type CloudwatchAdapter struct { Route *router.Route OsHost string Ec2Region string Ec2Instance string // contains filtered or unexported fields }
CloudwatchAdapter is an adapter that streams JSON to AWS CloudwatchLogs. It mostly just checkes ENV vars and other container info to determine the LogGroup and LogStream for each message, then sends each message on to a CloudwatchBatcher, which batches messages for upload to AWS.
func (*CloudwatchAdapter) Stream ¶
func (a *CloudwatchAdapter) Stream(logstream chan *router.Message)
Stream implements the router.LogAdapter interface.
type CloudwatchBatch ¶
type CloudwatchBatch struct { Msgs []CloudwatchMessage Size int64 }
func NewCloudwatchBatch ¶
func NewCloudwatchBatch() *CloudwatchBatch
func (*CloudwatchBatch) Append ¶
func (b *CloudwatchBatch) Append(msg CloudwatchMessage)
type CloudwatchBatcher ¶
type CloudwatchBatcher struct { Input chan CloudwatchMessage // contains filtered or unexported fields }
CloudwatchBatcher receieves Cloudwatch messages on its input channel, stores them in CloudwatchBatches until enough data is ready to send, then sends each CloudwatchMessageBatch on its output channel.
func NewCloudwatchBatcher ¶
func NewCloudwatchBatcher(adapter *CloudwatchAdapter) *CloudwatchBatcher
constructor for CloudwatchBatcher - requires the adapter
func (*CloudwatchBatcher) RunTimer ¶
func (b *CloudwatchBatcher) RunTimer()
func (*CloudwatchBatcher) Start ¶
func (b *CloudwatchBatcher) Start()
Main loop for the Batcher - just sorts each messages into a batch, but submits the batch first and replaces it if the message is too big.
type CloudwatchMessage ¶
type CloudwatchMessage struct { Message string `json:"message"` Group string `json:"group"` Stream string `json:"stream"` Time time.Time `json:"time"` Container string `json:"container"` }
CloudwatchMessage is a simple JSON input to Cloudwatch.
type CloudwatchUploader ¶
type CloudwatchUploader struct { Input chan CloudwatchBatch // contains filtered or unexported fields }
CloudwatchUploader receieves CloudwatchBatches on its input channel, and sends them on to the AWS Cloudwatch Logs endpoint.
func NewCloudwatchUploader ¶
func NewCloudwatchUploader(adapter *CloudwatchAdapter) *CloudwatchUploader
func (*CloudwatchUploader) Start ¶
func (u *CloudwatchUploader) Start()
Main loop for the Uploader - POSTs each batch to AWS Cloudwatch Logs, while keeping track of the unique sequence token for each log stream.
type RenderContext ¶
type RenderContext struct { Host string // container host name Env map[string]string // container ENV Labels map[string]string // container Labels Name string // container Name ID string // container ID LoggerHost string // hostname of logging container (os.Hostname) InstanceID string // EC2 Instance ID Region string // EC2 region }