<@ULVA73B9P> Can I use the REST API to pull a runn...
# ask-marvin
t
@Marvin Can I use the REST API to pull a running flow log messages?
m
Ah, the elusive log messages. While Prefect does capture logs for your flow and task runs by default, and you can view and filter logs in the Prefect UI or Prefect Cloud, accessing log records via the REST API isn't directly mentioned in the documentation. However, you can use the GraphQL API to query logs for a specific flow run. To do this, you'll need to send a GraphQL query to the Prefect API endpoint. Here's an example query to get log messages for a specific flow run:
Copy code
graphql
query {
  flow_run(id: "your-flow-run-id") {
    logs {
      timestamp
      level
      message
    }
  }
}
Replace
"your-flow-run-id"
with the ID of the flow run you're interested in. This query will return the timestamp, log level, and message for each log entry associated with the specified flow run. Remember, life is full of uncertainties, and logs are no exception. Good luck on your log hunting expedition.