在 Airflow 中设置 S3 日志记录

Setting up S3 logging in Airflow

这让我抓狂。

我正在云环境中设置气流。我有一台服务器 运行 连接调度程序和网络服务器,还有一台服务器作为 celery worker,我使用的是 airflow 1.8.0。

运行 工作正常。 拒绝 工作的是日志记录。

我在两台服务器的 airflow.cfg 中设置了正确的路径:

remote_base_log_folder = s3://my-bucket/airflow_logs/

remote_log_conn_id = s3_logging_conn

我已经在 airflow UI 中设置了 s3_logging_conn,使用访问密钥和秘密密钥

我使用

检查了连接

s3 = airflow.hooks.S3Hook('s3_logging_conn')

s3.load_string('test','test',bucket_name='my-bucket')

在两台服务器上都有效。因此连接已正确设置。然而,每当我 运行 一项任务时,我得到的只是

*** Log file isn't local.

*** Fetching here: http://*******

*** Failed to fetch log file from worker.

*** Reading remote logs...

Could not read logs from s3://my-bucket/airflow_logs/my-dag/my-task/2018-02-15T21:46:47.577537

我尝试按照预期的约定手动上传日志,但网络服务器仍然无法接收它 - 所以问题出在两端。我不知所措,到目前为止我读过的所有内容都告诉我 应该 有效。我即将安装 1.9.0,我听到更改日志记录,看看我是否更幸运。

更新:我全新安装了 Airflow 1.9 并按照特定说明进行操作

网络服务器现在甚至无法启动,出现以下错误:

airflow.exceptions.AirflowConfigException: section/key [core/remote_logging] not found in config

this config template 明确引用了此部分。

所以我尝试删除它并加载 S3 处理程序而不先检查,但我收到了以下错误消息:

Unable to load the config, contains a configuration error.

Traceback (most recent call last):

File "/usr/lib64/python3.6/logging/config.py", line 384, in resolve:

self.importer(used)

ModuleNotFoundError: No module named

'airflow.utils.log.logging_mixin.RedirectStdHandler';

'airflow.utils.log.logging_mixin' is not a package

我觉得这不应该这个难。

任何帮助将不胜感激,干杯

已解决:

  1. 升级到 1.9
  2. 运行描述的步骤
  3. 已添加

    [core]

    remote_logging = True

    到airflow.cfg

  4. 运行

    pip install --upgrade airflow[log]

现在一切正常。