I would like to add the ability to send prefect logs to a sql server table. Is there a way to accomplish this?
Hey, a couple of questions first:
- Are you on Prefect Cloud or self-hosted?
- If self-hosted, do you use SQLite or Postgres?
- What Prefect version do you use?
- Why would you need those logs to be in SQL Server?
Generally, there are a couple of ways to do that, depending on how fast you would need to get that data:
- Redirect logs
- Do database replication to get the entire logs table to SQL Server
- Use an EL tool such as Airbyte/Fivetran to run data replication
I’m assuming its self hosted. To my knowledge we are just using the prefect library. We are using prefect 2.2.0 and SQL Server. Ultimately we just want the logs stored so that we can go view them if we encounter an error. We will run our scripts on a server that has a monitoring service that will send emails to us if there is an error but we want the ability to store the logs if an error does occur so we can go back and see what the issue was.
You can do that from the Prefect UI directly - the UI is really excellent, I highly encourage you to give it a try and have a look, you’re gonna love that experience of inspecting the logs this way
Also here, Prefect already has a Notifications feature allowing you to get notified when any flow run fails - check out: