Hristo Mavrodiev
09/27/2025, 2:50 PMMarvin
09/27/2025, 2:50 PMMarvin
09/27/2025, 2:53 PMapiVersion: batch/v1
kind: Job
spec:
ttlSecondsAfterFinished: 86400 # keep for 1 day
template:
spec:
containers:
- name: flow
...
- Then you can fetch logs with:
kubectl logs job/<job-name> -n <namespace>
# or by pod:
kubectl logs <pod-name> -n <namespace>
- The pod could not send logs to Prefect
- Verify the job/worker has network egress to the Prefect API and correct env vars:
- PREFECT_API_URL
(and PREFECT_API_KEY
for Cloud)
- If the run finished but you see no flow logs in the UI, this is often a connectivity issue.
- Logging level is too high
- Ensure logs aren’t suppressed. In 3.x you can lower the root log level via:
- PREFECT_LOGGING_ROOT_LEVEL=INFO
(or DEBUG)
- Also make sure your code is actually logging:
from prefect import flow, get_run_logger
@flow
def demo():
logger = get_run_logger()
<http://logger.info|logger.info>("Hello from the flow!")
- You’re looking for worker logs vs. flow run logs
- Flow run logs are on the Flow Run page in the UI.
- Worker logs (the long-running process started with prefect worker start
) are best viewed via your cluster logs:
kubectl logs deploy/<worker-deployment> -n <namespace>
In the Prefect UI, Work Pools > Workers can show recent worker logs, but long-term retention relies on your cluster logging.
Quick ways to locate the right pod:
- By job name (if you know it): kubectl logs job/<job-name> -n <ns>
- By labels (replace with your flow run id): kubectl get pods -n <ns> -l <http://prefect.io/flow-run-id=<FLOW_RUN_ID|prefect.io/flow-run-id=<FLOW_RUN_ID>>
Relevant docs:
- Prefect logs API and retrieval: Read logs via API
- Logging customization in 3.x: Logging customization
- Kubernetes deployment/job guidance: Kubernetes how-to
If you can share:
- A link or ID for an example flow run with missing logs
- Your work pool type and base job template (if using a Kubernetes work pool)
- Whether the pod still exists (output of kubectl get pods -n <ns>
)
…I can pinpoint the exact cause and suggest a precise fix.