Can't view running tasks logs using KubernetesExecutor.
See original GitHub issueDescription
I want to be able to see logs for running tasks in airflow web UI when I’m using “KubernetesExecutor”. Airflow tries to read logs of worker pod which does not contain my task logs because “airflow tasks run” command redirects all stdout/stderr to log file.
Here is what I see when I try to read logs of running tasks:
*** Falling back to local log
*** Trying to get logs (last 100 lines) from worker pod datainfraexporterhourlydagwaitforpublishedpostdump.a825336790e24b40ad43b2411ef617c5 ***
BACKEND=postgres
DB_HOST=divar-infra-db-cluster-master-service.skubel-76f219d5-eb73-4f23-96b3-a8cf4ab4f00a
DB_PORT=5432
[[34m2021-05-22 19:00:30,157[0m] {[34mdagbag.py:[0m451} INFO[0m - Filling up the DagBag from /git/airflow/dags/data_infra/exporter/hourly.py[0m
Use case / motivation
It’s not convenient to wait for tasks to finish in order to read their logs.
Are you willing to submit a PR?
I can help.
Related Issues
I don’t think so.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Cant get Kubernetes task's log when using ... - GitHub
Once you have got that fixed, log will be empty in the running state, because it is trying to read container logs and...
Read more >Unable to see Task logs in Airflow Deployed via Kubernetes
Was currently using Airflow 2.0.2 release and installing it via its latest Helm chart using the Kubernetes executor. I also had to set...
Read more >Kubernetes Executor — Airflow Documentation - Apache Airflow
When a DAG submits a task, the KubernetesExecutor requests a worker pod from the Kubernetes API. The worker pod then runs the task,...
Read more >"Log file does not exist" - Astronomer Nebula
Is it a problem with my task, or astronomer cloud, or airflow? *** Log file does not exist: /usr/local/airflow/logs/[TASKNAME]s/run/2019-07- ...
Read more >Running Apache Airflow Workflows on a Kubernetes Cluster
In this series, our goal is to show how to deploy Apache Airflow on ... to use Kubernetes Executor when running task instances...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I came up with a solution today. I changed the default logging config class like this:
I moved this file to
$AIRFLOW_HOME/config/logging_config.py
and changedAIRFLOW__LOGGING__LOGGING_CONFIG_CLASS
tologging_config.LOGGING_CONFIG
I’ve had this issue for a while now, but I was able to resolve it by adding this to the top of my
dag.py
file.It does pretty much what @hsnprsd had in his class, but doesn’t require overriding the default logging config.