Noah Holm
10/21/2025, 2:58 PMMarvin
10/21/2025, 2:58 PMMarvin
10/21/2025, 3:04 PMprefect block inspect <BLOCK_TYPE_SLUG>/<BLOCK_NAME>
- Variable details (shows created/updated):
prefect variable inspect <NAME>
- API references (created/updated fields):
- Blocks REST API
- Variables REST API
- CLI docs: prefect block, prefect variable
If you need true “last used” tracking:
- Emit a custom event whenever you load a block or read a variable, then use the Events view (or an Automation) to report the latest occurrence. Events docs: Events
Example wrappers you can use in your flows:
- Track variable access
from prefect.variables import Variable
from prefect.events.utilities import emit_event
def tracked_variable_get(name: str, default=None):
value = Variable.get(name, default=default)
emit_event(
event="variable.used",
resource={
"prefect.resource.id": f"variable/{name}",
"prefect.resource.role": "variable",
},
payload={"name": name},
)
return value
- Track block usage
from prefect.blocks.core import Block
from prefect.events.utilities import emit_event
def tracked_block_load(block_cls: type[Block], name: str):
block = block_cls.load(name)
emit_event(
event="block.used",
resource={
"prefect.resource.id": f"block/{block_cls.__name__}/{name}",
"prefect.resource.role": "block",
},
payload={"block_type": block_cls.__name__, "name": name},
)
return block
How to review usage once emitting events:
- In Cloud, open Events and filter for block.used or variable.used.
- Or stream in the CLI for quick checks:
prefect events stream --format text
(Press Ctrl+C to stop.)
If you’d like, I can help you:
- Add these wrappers centrally (so all reads are tracked),
- Create a small flow/automation that aggregates “last used” per block/variable and writes a report.