<@ULVA73B9P> how can I see the worker logs on pref...
# ask-marvin
k
@Marvin how can I see the worker logs on prefect 3.x running in an azure container instance?
m
To view worker logs for Prefect 3.x running in an Azure Container Instance, you'll need to set up and configure a Prefect ACI worker properly. Here are the general steps and resources you can refer to: 1. Container Creation: First, ensure that your container instance in Azure is created with the Prefect ACI worker setup. The Prefect documentation provides a detailed guide on creating and configuring the ACI worker. Check this ACI Worker Setup Guide for more information. 2. Accessing Logs: Once your ACI worker is running, you should be able to view the logs directly from the Azure Portal. Navigate to the Azure Container Instance you created, and under the "Containers" section, you typically have an option to view logs. This will provide you logs related to the Prefect worker and any tasks or flows it runs. 3. Audit Logs in Prefect Cloud: If you're using Prefect Cloud, you can also monitor some activities with audit logs, particularly useful for security and compliance purposes. These logs provide insights into who performed certain actions and might help in diagnosing issues. You can learn more about audit logs here. Unfortunately, there were no specific GitHub issues related to worker logs in Azure. If these resources don't entirely address your needs, you might consider reaching out to the community or support groups associated with Prefect for more tailored assistance.
k
@Marvin how do I set the logging level on a worker to debug?
m
To set the logging level on a Prefect 3.x worker to "DEBUG", you can adjust the logging level through environment variables or using the Prefect CLI. Here’s how you can do it: 1. Using the Prefect CLI: You can set the logging level to debug by running the following command:
Copy code
prefect config set PREFECT_LOGGING_LEVEL=DEBUG
2. Using Environment Variables: Alternatively, you can set the logging level using environment variables. You can do this by exporting the variable as follows:
Copy code
export PREFECT_LOGGING_LEVEL=DEBUG
These settings ensure that the worker logs additional details, helping you troubleshoot any issues with more granularity. Keep in mind that the "DEBUG" level will produce a high volume of logs, so use it cautiously. For more information on logging customization, you can refer to the following resources: - Troubleshoot Cloud - Develop: Logging
upvote 1
n
yeah i would inject that env var wherever you start the worker processzx
k
How would I do that Nate? adding arguments to the command line? i.e. prefect worker start --pool
n
depends how you're starting the worker, on my unix based machine i can do
Copy code
» PREFECT_LOGGING_LEVEL=DEBUG prefect worker start -p local
15:21:31.051 | DEBUG   | prefect.profiles - Using profile 'bleeding'
15:21:31.115 | DEBUG   | prefect.client - Connecting to API at <http://localhost:4200/api/>
...
but if you're starting some ACI service that runs your worker, that might look a bit different
essentially you just need to
export PREFECT_LOGGING_LEVEL=DEBUG
on whatever machine is running your worker
Copy code
» docker run --rm prefecthq/prefect:3.0.4-python3.12 -- echo "PREFECT_LOGGING_LEVEL=DEBUG" > .env && prefect worker start -p local
15:24:29.453 | DEBUG   | prefect.profiles - Using profile 'bleeding'
15:24:29.541 | DEBUG   | prefect.client - Connecting to API at <http://localhost:4200/api/>
you can even just put stuff in an
.env
wherever you start your worker if that ends up being useful
k
once I apply the configuration change do I need to restart the worker?
n
yeah, bc the settings would be loaded from the env when the process starts
k
can the be done from the prefect cli?
n
no not in general its just wherever you ran
prefect worker start
you'd kill / restart that process
k
thanks Nate, I created a new worker in the same aci and found a new error to chase 😂 . Appreciate the help
n
it is like that sometimes 🙃 good luck! sure thing