Add a new way to consume logs
First check
- I added a descriptive title to this issue.
- I used the GitHub search to find a similar request and didn't find it.
- I searched the Prefect documentation for this feature.
Prefect Version
2.x
Describe the current behavior
Right now, the only way to read logs in the UI is to store them and retrieve them through the database. This is a problem for us because our logs take a lot of space and we want to keep the log for a long period of time. We created a custom log handler that allows us to push our log in our datalake but we lose the integration with the prefect log system.
Describe the proposed behavior
We would like to have a way the inject a log consumer that would change the behavior of the route that retrieve the log. So everybody could implement their log consumer if they want to
Example Use
We could define our consumer like this:
class MyLogConsumer:
def read(offset: int, limit: int, logs: LogFilter, sort: LogSort) -> List[Log]:
...And use it like this:
PREFECT_LOG_CONSUMER="my_lib.log.MyLogConsumer" prefect server startAdditional context
The code that would need to be modified is located here: https://github.com/PrefectHQ/prefect/blob/0792e60db3749599230eed289f44b75d274de649/src/prefect/server/api/logs.py#L41
Source: PrefectHQ/prefect