Skip to content

noxdafox/lager_cloudwatch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lager Backend for AWS CloudWatch

Lager backend for forwarding log messages to AWS CloudWatch.

Configuration

Configure a Lager handler like the following:

{lager_cloudwatch_backend, [Level, LogGroupName, LogStreamName]}

The backend will take care of creating the Log Group and Stream if non existing. Make sure the service has the correct permissions to do so. If the LogStreamName is undefined or omitted, the backend will use the node name as Log Stream name.

The backend accepts custom message formatters and related formatting configurations in the form {Formatter, Format}. If omitted or undefined a default message format will be used.

Example:

{lager_cloudwatch_backend, [info,
                            "ExampleLogGroup",
                            "ExampleLogStream",
                            {lager_default_formatter, [time, " ", "[", severity ,"] ", " ", message, "\n"]}]}

AWS CloudWatch has a fixed quota of five requests per second per each stream. To avoid being throttled, the backend batches all incoming log messages in periods of one second. The period duration can be passed as additional parameter to the handler configuration.

{lager_cloudwatch_backend, [Level, LogGroupName, LogStreamName, LogFormatter, LogPeriodMilliseconds]}

Example:

{lager_cloudwatch_backend, [info, "ExampleLogGroup", "ExampleLogStream", undefined, 3000]}

AWS Configuration

The Lager backend relies on erlcloud APIs to interface with AWS services.

To configure AWS specific parameters, simply refer to erlcloud README instructions.

Build

$ rebar3 compile