Logs not visible on UI , how to fix this ?
# prefect-community
m
Logs not visible on UI , how to fix this ?
discourse 1
a
Are you on Prefect Cloud? Normally, you should be able to refresh your browser page and see the logs then.
m
No, hosted on personal server
a
hmm could it be there is some issue with your Postgres instance running out of storage and not being able to store logs? checking logs could be informative
m
do you know the path where this logs are stored ?
k
It’s a
logs
table in the postgresdb
a
@Muddassir Shaikh what I meant that checking the Server logs would be useful to see If you see any error messages such as "no space left on Disk, couldn't insert flow run logs to the DB"
m
while setting up prefect, i didnt specify any database and installation was done automatic, can you guide me with the path of the postgresdb which it uses ?
k
If you do
prefect server start
, it uses Docker compose to spin up multiple containers. There will be a postgres container which contains your Flows and metadata and logs
p
@Kevin Kho @Anna Geller We don't see any server errors/postgres errors on the prefect server on the docker logs Also do note that we are experiencing this for one of the agents - rest agents are fine - so don't think it will be a space issue. What else could be the reason for this?
Also what set of username, password and database we should use if we have to connect to the postgresql ?
k
If you use prefect server start, it’s here
p
okay can connect to the database and can see the log table but don't see any logs from only one agent
k
You mean from the flows run on the agent? Or are you expecting agent logs to show up?
p
I am expecting the logs of the flow runs on the agent
a
To see flow run logs on the agent, you need to start your agent with a flag --show-flow-logs:
Copy code
prefect agent local start --show-flow-logs
m
@Anna Geller i added showflow log flag still the logs are not visible on the UI. below is my agent startup command:
Copy code
prefect agent local start -l my_agent_name -n my_agent_name -a <http://hosted_prefect_server_ip>:port -p /home/code/utils --show-flow-logs
a
can you show the flow code of the flow that doesn't generate logs properly?
if you use print, you need to add log_stdout=True to the task decorator, and to log from tasks, you need to use logger from the context:
Copy code
@task
def do_sth():
    logger = prefect.context.get("logger")
    <http://logger.info|logger.info>("some msg")
logging within flows is not supported in Prefect 1.0
m
naah there is no issue in code as when i run the same code from different agent, logs are shown on UI. But i do see differences in prefect version of those agents
This is fixed now. The issue was with prefect version. The prefect server had prefect version = 0.15.11 and this new agent had version=1.1.0. I downgraded it to 0.15.11 and now logs are visible on UI. Thanks @Anna Geller @Kevin Kho @Prateek Saigal for your time 😄
a
Great work finding and fixing the issue! 👏
187 Views