删除 Airflow Scheduler 日志

2024-03-14

我正在使用 Docker Apache Airflow 版本 1.9.0-2 (https://github.com/puckel/docker-airflow https://github.com/puckel/docker-airflow).

调度程序生成大量日志,文件系统将很快耗尽空间,因此我尝试以编程方式删除由airflow创建的调度程序日志,这些日志位于 (/usr/local/airflow/logs/scheduler 中的调度程序容器中) )

我设置了所有这些维护任务:https://github.com/teamclairvoyant/airflow-maintenance-dags https://github.com/teamclairvoyant/airflow-maintenance-dags

但是,这些任务仅删除worker上的日志,而调度程序日志位于调度程序容器中。

我还设置了远程日志记录,将日志发送到 S3,但正如这篇 SO 帖子中提到的删除 Airflow 任务日志 https://stackoverflow.com/questions/43548744/removing-airflow-task-logs此设置不会阻止气流写入本地计算机。

此外,我还尝试在工作程序和调度程序之间创建一个共享命名卷,如此处所述Docker Compose - 在多个容器之间共享命名卷 https://stackoverflow.com/questions/44284484/docker-compose-share-named-volume-between-multiple-containers。但是,我在工作人员中收到以下错误:

ValueError: Unable to configure handler 'file.processor': [Errno 13] Permission denied: '/usr/local/airflow/logs/scheduler'

以及调度程序中出现以下错误:

ValueError: Unable to configure handler 'file.processor': [Errno 13] Permission denied: '/usr/local/airflow/logs/scheduler/2018-04-11'

那么,人们如何删除调度程序日志?


灵感来自this https://stackoverflow.com/a/46197914/4245534回复,我已经添加了airflow-log-cleanup.pyDAG(对其参数进行了一些更改)来自here https://github.com/teamclairvoyant/airflow-maintenance-dags/tree/master/log-cleanup去除all旧的气流日志,包括调度程序日志。

我的更改很小,除了考虑到我的 EC2 磁盘大小(7.7G)/dev/xvda1),默认值为 30 天DEFAULT_MAX_LOG_AGE_IN_DAYS看起来太大了,所以(我有 4 个 DAG)我将其更改为 14 天,但请随意根据您的环境进行调整:

DEFAULT_MAX_LOG_AGE_IN_DAYS = Variable.get("max_log_age_in_days", 30)变成DEFAULT_MAX_LOG_AGE_IN_DAYS = Variable.get("max_log_age_in_days", 14)

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

删除 Airflow Scheduler 日志 的相关文章

随机推荐