Cloudwatch repository
Stores the events as JSON log events in an AWS CloudWatch log group. See CloudWatch configuration for the options, the permissions and the limitations.
__init__(credentials=None, log_group=None, log_stream=None)
CloudWatch repository.
| PARAMETER | DESCRIPTION |
|---|---|
credentials
|
AWS credentials. If not provided, the extension configuration will be used.
TYPE:
|
log_group
|
Log group name. If not specified, the configured log group will be used.
TYPE:
|
log_stream
|
Log stream name. If not specified, the configured log stream will be used.
TYPE:
|
Note
The repository is a singleton, so this runs on every
CloudWatchRepository() call. Once the client is set up, calls
without arguments reuse it; passing any argument sets the
repository up again with the given values.
filter_events(filters)
Filters events based on provided filter criteria.
| PARAMETER | DESCRIPTION |
|---|---|
filters
|
filters to apply.
TYPE:
|
get_event(event_id)
Retrieves a single event from the repository.
| PARAMETER | DESCRIPTION |
|---|---|
event_id
|
event ID.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Event | None
|
types.Event | None: event object or None if not found. |
remove_all_events()
Removes all events from the repository.
Deleting the log group also deletes its log stream, so the group is
recreated immediately (empty) and the cached "stream exists" state
is reset. Without this, every subsequent write would fail with
ResourceNotFoundException until the process restarts.
| RETURNS | DESCRIPTION |
|---|---|
Result
|
types.Result: result of the operation. |
remove_event(event_id)
Remove operation is not supported for CloudWatch logs.
As of today, you cannot delete a single log event from CloudWatch log stream, the alternative will be using Lambda functions: set a Lambda function trigger, filter all logs, then write the remaining logs to a new log group/stream, then delete the original log stream.
It's potentially too expensive to do this operation, so it's not implemented.
Note
The remove single event operation is not supported
remove_events(filters)
See remove_event method docstring.
test_connection()
Tests the connection to the repository.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
whether the connection was successful.
TYPE:
|
write_event(event)
Writes a single event to the repository.
| PARAMETER | DESCRIPTION |
|---|---|
event
|
event to write.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Result
|
types.Result: result of the operation. |
write_events(events)
Writes multiple events to the repository.
Events are batched into as few put_log_events calls as possible
(CloudWatch caps a single call at 10,000 events / 1 MB), instead of
one put_log_events (plus a redundant create_log_stream) per
event.
| PARAMETER | DESCRIPTION |
|---|---|
events
|
events to write.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Result
|
types.Result: result of the operation. |