I believe you could use state handlers to populate a postgres db, or anywhere really:
https://docs.prefect.io/core/concepts/notifications.html#state-handlers
Also, the newly released prefect server stores metadata at its own postgres server, which is used to provide you with information in the prefect server UI. That may be too overkill a solution to just store metadata though.