airflow.providers.amazon.aws.hooks.logs

Module Contents

Classes

AwsLogsHook

Interact with Amazon CloudWatch Logs.

Attributes

NUM_CONSECUTIVE_EMPTY_RESPONSE_EXIT_THRESHOLD

airflow.providers.amazon.aws.hooks.logs.NUM_CONSECUTIVE_EMPTY_RESPONSE_EXIT_THRESHOLD = 3[source]
class airflow.providers.amazon.aws.hooks.logs.AwsLogsHook(*args, **kwargs)[source]

Bases: airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook

Interact with Amazon CloudWatch Logs.

Provide thin wrapper around boto3.client("logs").

Additional arguments (such as aws_conn_id) may be specified and are passed down to the underlying AwsBaseHook.

class ContinuationToken[source]

Just a wrapper around a str token to allow updating it from the caller.

get_log_events(log_group, log_stream_name, start_time=0, skip=0, start_from_head=None, continuation_token=None, end_time=None)[source]

Return a generator for log items in a single stream; yields all items available at the current moment.

Parameters
  • log_group (str) – The name of the log group.

  • log_stream_name (str) – The name of the specific stream.

  • start_time (int) – The timestamp value in ms to start reading the logs from (default: 0).

  • skip (int) – The number of log entries to skip at the start (default: 0). This is for when there are multiple entries at the same timestamp.

  • start_from_head (bool | None) – Deprecated. Do not use with False, logs would be retrieved out of order. If possible, retrieve logs in one query, or implement pagination yourself.

  • continuation_token (ContinuationToken | None) – a token indicating where to read logs from. Will be updated as this method reads new logs, to be reused in subsequent calls.

  • end_time (int | None) – The timestamp value in ms to stop reading the logs from (default: None). If None is provided, reads it until the end of the log stream

Returns

A CloudWatch log event with the following key-value pairs:
’timestamp’ (int): The time in milliseconds of the event.
’message’ (str): The log event data.
’ingestionTime’ (int): The time in milliseconds the event was ingested.

Return type

Generator

Was this entry helpful?