<@ULVA73B9P> I am using prefect3. When I run a flo...
# ask-marvin
c
@Marvin I am using prefect3. When I run a flow in a k8s job (that was created by a k8s worker), I don't get the crash logs in the server UI, only in the job pod (and worker pod). What I need to do to receive the crash logs as well (the logs from prefect.engine and prefect.flow_engine).
m
To receive crash logs from Prefect flows running in Kubernetes jobs, you need to ensure that the logging configuration is properly set up to propagate logs from the Kubernetes environment to the Prefect server. Here's a concise guide: 1. Set Logging Level: Increase the logging level to DEBUG to capture more detailed logs. This can be done using environment variables or the
prefect config set
CLI command. Note that DEBUG level logs can be verbose, so revert back to INFO once the issue is resolved. 2. Log Configuration in Flows: Use
get_run_logger()
to retrieve a logger instance within your flows or tasks. This ensures that logs are directed to the Prefect logger and subsequently to the Prefect server. 3. Log Prints: Enable the
log_prints
option in your flows and tasks to automatically redirect print statements to the Prefect logger. This is particularly useful if you have print statements that aren't captured by default logging. 4. Kubernetes Job Template: Customize the Kubernetes job template to include any additional logging configurations necessary for your environment. This might involve modifying the base job template to ensure logs are captured and sent to the appropriate destinations. 5. Check Worker Logs: Sometimes, logs are only available where the worker is running. Ensure that your worker has the correct permissions and configurations to send logs to the Prefect server. For more detailed guidance, you can refer to the Prefect documentation: - Logging in Prefect - Troubleshooting in Prefect Cloud - Kubernetes Deployment If these steps don't resolve the issue, consider reviewing the worker's configuration and network settings to ensure they allow for proper log transmission.