<@ULVA73B9P> how can i get more detail than just t...
# ask-marvin
r
@Marvin how can i get more detail than just this when running a flow in prefect-managed infra:
Copy code
Flow run infrastructure exited with non-zero status code:
 Essential container in task exited (Error Code: 1)
m
thought for 213.3 seconds
That message usually means the container died before Prefect could surface a Python traceback. Here are a few ways to get more detail when using Prefect-managed (hosted) infrastructure: 1) Check infra logs in the UI - Open the flow run → Logs tab. - Enable/expand infrastructure logs to see the container’s stdout/stderr (dependency installation, import errors, etc.). If you don’t see infra logs on that run, let me know which run ID it is and I’ll take a look. 2) Pull logs via the CLI - Tail recent logs:
Copy code
prefect flow-run logs <RUN_ID> --tail -n 500
- Inspect the run details (exit code, crash reason):
Copy code
prefect flow-run inspect <RUN_ID>
3) Turn up verbosity and capture prints - Set
PREFECT_LOGGING_LEVEL=DEBUG
on the deployment (environment variables) or as work pool job variables to get more detailed Prefect logs. - Capture
print()
output in your logs by enabling
log_prints
on your flow:
Copy code
from prefect import flow, get_run_logger

@flow(log_prints=True)
def my_flow():
    logger = get_run_logger()
    <http://logger.info|logger.info>("Starting flow...")
    print("This will appear in Prefect logs too")
- More logging tips: Prefect 3 logging customization 4) Watch for common root causes in hosted runs - Missing deps or import errors: You’ll typically see pip/install output or a Python ImportError in infrastructure logs. Ensure your project dependencies are declared (and pinned) so the hosted runner installs them. - Python version mismatch: If your code requires a specific Python version, declare it in your project so hosted infra uses the right interpreter. - OOM/CPU starvation: If you see exit code 137 or messages about being killed, it’s an out-of-memory kill. Increase memory/CPU on your Prefect-hosted work pool (in the work pool’s settings) or via job variables for that run. If you share a specific flow run ID (and whether you’re on Prefect 3), I can point you directly to where the infra logs should appear and help interpret the exit code you’re seeing.