首页 > 解决方案 > 使用 DaskExecutor 的 Airflow 实时执行程序日志

问题描述

我有一个 Airflow 安装(在 Kubernetes 上)。我的设置使用DaskExecutor. 我还将远程日志记录配置到 S3。但是,当任务运行时,我看不到日志,而是收到此错误:

*** Log file does not exist: /airflow/logs/dbt/run_dbt/2018-11-01T06:00:00+00:00/3.log
*** Fetching from: http://airflow-worker-74d75ccd98-6g9h5:8793/log/dbt/run_dbt/2018-11-01T06:00:00+00:00/3.log
*** Failed to fetch log file from worker. HTTPConnectionPool(host='airflow-worker-74d75ccd98-6g9h5', port=8793): Max retries exceeded with url: /log/dbt/run_dbt/2018-11-01T06:00:00+00:00/3.log (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f7d0668ae80>: Failed to establish a new connection: [Errno -2] Name or service not known',))

任务完成后,日志将正确显示。

我相信 Airflow 正在做的是:

看起来 Airflow 正在使用celery.worker_log_server_port连接到我的 dask 执行程序以从那里获取日志。

如何配置DaskExecutor暴露日志服务器端点

我的配置:

core    remote_logging          True 
core    remote_base_log_folder  s3://some-s3-path
core    executor                DaskExecutor    
dask    cluster_address         127.0.0.1:8786
celery  worker_log_server_port  8793    

我验证了什么: - 验证了日志文件存在并且在任务运行时正在写入到执行器上 -netstat -tunlp在执行器容器上调用,但没有发现任何额外的端口暴露,可以从中提供日志。

标签: airflowdask

解决方案


更新 看看serve_logs气流 cli 命令 - 我相信它完全一样。


我们通过简单地在 worker 上启动 python HTTP 处理程序解决了这个问题。

Dockerfile:

RUN mkdir -p $AIRFLOW_HOME/serve
RUN ln -s $AIRFLOW_HOME/logs $AIRFLOW_HOME/serve/log

worker.sh(由 Docker CMD 运行):

#!/usr/bin/env bash

cd $AIRFLOW_HOME/serve
python3 -m http.server 8793 &

cd -
dask-worker $@

推荐阅读