agent

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: MIT Imports: 15 Imported by: 0

README

cloudwatch-logs-agent-lite

Lightweight log forwarder with CloudWatch

SYNOPSIS

Read logs from STDIN:

$ echo Hello | cloudwatch-logs-agent-lite -log-group-name /test
$ aws logs tail
2022-10-29T08:34:07.441000+00:00 ichinoseshougonoMacBook-Pro.local Hello

Read logs from the log file access.log:

$ cloudwatch-logs-agent-lite -log-group-name /test access.log &
$ echo Hello >> access.log
$ aws logs tail
2022-10-29T08:34:07.441000+00:00 ichinoseshougonoMacBook-Pro.local Hello

USAGE

Usage of cloudwatch-logs-agent-lite:
  -flush-interval duration
    	interval to flush the logs (default 5s)
  -flush-timeout duration
    	timeout to flush the logs (default 3m0s)
  -log-group-name string
    	log group name
  -log-level string
    	minimum log level. Possible values are: debug, info, warn, error (default "info")
  -log-retention-days int
    	Specifies the number of days you want to retain log events in the specified log group. Possible values are: 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, 3653
  -log-stream-name string
    	log stream name
  -region string
    	aws region
  -version
    	show the version

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	*Writer

	// Files are target file names for tailing.
	// If the length of Files is zero, the standard input is used.
	Files []string

	// FlushInterval specifies the interval
	// to flush to the logs.
	// If zero, no periodic flushing is done.
	FlushInterval time.Duration

	// FlushTimeout specifies the timeout
	// to flush to the logs.
	// If zero, flushing is never timeout.
	FlushTimeout time.Duration
	// contains filtered or unexported fields
}

Agent is a CloudWatch Logs Agent Lite.

func (*Agent) Close

func (a *Agent) Close() error

Close stops log forwarding.

func (*Agent) Start

func (a *Agent) Start() error

Start starts log forwarding.

func (*Agent) Wait added in v0.0.3

func (a *Agent) Wait()

Wait waits for all readers are closed.

type Writer

type Writer struct {
	Config           aws.Config
	LogGroupName     string
	LogStreamName    string
	LogRetentionDays int
	// contains filtered or unexported fields
}

Writer is a wrapper CloudWatch Logs that provides io.Writer interface.

func (*Writer) Close

func (w *Writer) Close() error

Close closes the Writer.

func (*Writer) CloseContext added in v0.0.9

func (w *Writer) CloseContext(ctx context.Context) error

CloseContexts closes the Writer.

func (*Writer) Flush

func (w *Writer) Flush() error

Flush is same as FlushContext, but it doesn't support the context.

func (*Writer) FlushContext added in v0.0.9

func (w *Writer) FlushContext(ctx context.Context) error

FlushContext flushes the logs to the AWS CloudWatch Logs.

func (*Writer) LastFlushedTime added in v0.0.11

func (w *Writer) LastFlushedTime() time.Time

LastFlushedTime returns the timestamp of the event most recently putted.

func (*Writer) Write

func (w *Writer) Write(p []byte) (int, error)

Write implements io.Writer interface.

func (*Writer) WriteContext added in v0.0.9

func (w *Writer) WriteContext(ctx context.Context, p []byte) (int, error)

WriteContext is same as Write, and it supports the context.

func (*Writer) WriteEvent

func (w *Writer) WriteEvent(now time.Time, message string) (int, error)

WriteEvent writes an log event.

func (*Writer) WriteEventContext added in v0.0.9

func (w *Writer) WriteEventContext(ctx context.Context, now time.Time, message string) (int, error)

WriteEventContext writes log events. Long message might be separated into multiple events.

func (*Writer) WriteString

func (w *Writer) WriteString(s string) (int, error)

WriteString writes a string.

func (*Writer) WriteStringContext added in v0.0.9

func (w *Writer) WriteStringContext(ctx context.Context, s string) (int, error)

WriteStringContext writes a string.

func (*Writer) WriteStringWithTime

func (w *Writer) WriteStringWithTime(now time.Time, s string) (int, error)

WriteStringWithTime writes data with timestamp.

func (*Writer) WriteStringWithTimeContext added in v0.0.9

func (w *Writer) WriteStringWithTimeContext(ctx context.Context, now time.Time, s string) (int, error)

WriteStringWithTimeContext writes data with timestamp.

func (*Writer) WriteWithTime

func (w *Writer) WriteWithTime(now time.Time, p []byte) (int, error)

WriteWithTime writes data with timestamp.

func (*Writer) WriteWithTimeContext added in v0.0.9

func (w *Writer) WriteWithTimeContext(ctx context.Context, now time.Time, p []byte) (int, error)

WriteWithTimeContext writes data with timestamp.

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

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