<@ULVA73B9P> Is it possible to list all currently ...
# ask-marvin
r
@Marvin Is it possible to list all currently running flows and their related deployments ?
m
thought for 415.2 seconds
Yes. Assuming Prefect 3.x, here are the easiest ways: - CLI (list running flow runs) - See all currently running flow runs:
Copy code
prefect flow-run ls --state RUNNING --limit 100
- Note: the CLI list does not include the deployment name in the table. For a single run you can inspect to see its `deployment_id`:
Copy code
prefect flow-run inspect <flow_run_id>
- Python (list running flow runs with their deployment names)
Copy code
import asyncio
  from prefect.client.orchestration import get_client
  from prefect.client.schemas.filters import FlowRunFilter
  from prefect.client.schemas.objects import StateType

  async def main():
      async with get_client() as client:
          runs = await client.read_flow_runs(
              flow_run_filter=FlowRunFilter(
                  state={"type": {"any_": [StateType.RUNNING]}}
              ),
              limit=200,
          )

          # Lookup deployment names (some runs may have no deployment)
          dep_names = {}
          for r in runs:
              if r.deployment_id and r.deployment_id not in dep_names:
                  dep = await client.read_deployment(r.deployment_id)
                  dep_names[r.deployment_id] = dep.name

          for r in runs:
              dep_name = dep_names.get(r.deployment_id, "None")
              print(f"{r.id}  {r.name}  deployment={dep_name}")

  asyncio.run(main())
- UI - Navigate to Flow Runs → filter by state “Running”. The table includes a Deployment column and lets you click through. If you’d prefer a different format (e.g., JSON output for scripting) or want to include the flow name as well, I can tweak the example.