airflow.providers.amazon.aws.log.cloudwatch_task_handler

Module Contents

class airflow.providers.amazon.aws.log.cloudwatch_task_handler.CloudwatchTaskHandler(base_log_folder: str, log_group_arn: str, filename_template: str)[source]

Bases: airflow.utils.log.file_task_handler.FileTaskHandler, airflow.utils.log.logging_mixin.LoggingMixin

CloudwatchTaskHandler is a python log handler that handles and reads task instance logs.

It extends airflow FileTaskHandler and uploads to and reads from Cloudwatch.

Parameters
  • base_log_folder (str) -- base folder to store logs locally

  • log_group_arn (str) -- ARN of the Cloudwatch log group for remote log storage with format arn:aws:logs:{region name}:{account id}:log-group:{group name}

  • filename_template (str) -- template for file name (local storage) or log stream name (remote)

hook(self)[source]

Returns AwsLogsHook.

_render_filename(self, ti, try_number)[source]
set_context(self, ti)[source]
close(self)[source]

Close the handler responsible for the upload of the local log file to Cloudwatch.

_read(self, task_instance, try_number, metadata=None)[source]
get_cloudwatch_logs(self, stream_name: str)[source]

Return all logs from the given log stream.

Parameters

stream_name -- name of the Cloudwatch log stream to get all logs from

Returns

string of all logs from the given log stream

Was this entry helpful?