airflow - 使用 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 正在做的是:
- 对于已完成的任务,从 s3 读取日志
- 对于运行任务,连接到执行器的日志服务器端点并显示。
看起来 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
在执行器容器上调用,但没有发现任何额外的端口暴露,可以从中提供日志。
解决方案
更新
看看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 $@
推荐阅读
- ios - 使用“required init?(coder aDecoder: NSCoder)”进行 IBOutlets 初始化时,我会遇到任何问题吗?如果是,有什么例子?
- firebase - 有没有办法在 React Native Expo 中实现 Google OAuth 而不会弹出?
- amazon-web-services - AWS VPC - 无法从私有子网中的堡垒主机通过 SSH 连接到不同子网中同一 VPC 中的 EC2 实例
- python - Scrapy KeyError:'Spider not found',但在终端中执行'scrapy list'时存在蜘蛛
- excel - Visual Basic 不保存工作表
- excel - 数据验证 - 您只能在列中写入两次相同的值
- c - 解压 16 位 BCD 的最有效公式?(例如 0x1234 到 0x01020304)
- mlr - MLR中是否有任何功能可以制作复杂的学习者
- twilio - 使用 SMS MFA (Twilio) 扩展 E2E 测试的方法
- google-cloud-platform - Google Cloud Resource Manager - 在文件夹中创建项目