<@ULVA73B9P> i am trying to get a flow to emit hea...
# ask-marvin
a
@Marvin i am trying to get a flow to emit heartbeats by setting the
PREFECT_RUNNER_HEARTBEAT_FREQUENCY
environment variable. i can see that the variable is set but i still do not see heartbeats when i run the flow
m
thought for 269.0 seconds
Got it. In Prefect 3.x, flow heartbeats are emitted by the runner when you set
PREFECT_RUNNER_HEARTBEAT_FREQUENCY
to a value in seconds. A few key points to make sure it works: - The setting is disabled by default; you must set it to a value >= 30 to enable heartbeats. - It must be present in the environment of the process that executes the flow (the worker/job container/pod or the shell where you run the flow), not just on your local machine or server UI. - Heartbeats are emitted only for runs that are connected to the Prefect API (Cloud or a Prefect Server). Local, offline runs without an API connection won’t emit heartbeats to the UI. How to set it - Temporary in your shell before starting your worker or running your flow:
Copy code
export PREFECT_RUNNER_HEARTBEAT_FREQUENCY=60
  prefect worker start -p <your-work-pool>
or if you’re running the flow locally but connected to the API:
Copy code
export PREFECT_RUNNER_HEARTBEAT_FREQUENCY=60
  prefect run -p <path/to/flow.py>:<flow_name>
- Persist it in your Prefect profile:
Copy code
prefect config set PREFECT_RUNNER_HEARTBEAT_FREQUENCY=60
- Verify it’s picked up:
Copy code
prefect config view --show-defaults --show-sources | grep HEARTBEAT
How to confirm heartbeats - In the Prefect UI, open the flow run and check the Events panel; you should see flow-run heartbeat events roughly every N seconds. - Optionally, create an Automation that triggers when a flow run is missing heartbeats for a period to catch “zombie” runs. See the docs below. Caveats - Minimum allowed is 30 seconds; values below 30 are invalid. - Tasks do not emit their own heartbeats; this is a flow-run heartbeat. - If you’re using deployments on Docker/Kubernetes workers, ensure the env var is set in the job/worker runtime environment (e.g., container/pod env). Docs - Detect zombie flows and heartbeats: Detect zombie flows - Settings reference: Settings reference Quick questions to help troubleshoot if you still don’t see heartbeats: - Are you running via a deployment and worker, or just executing the flow script locally? - Cloud or self-hosted Server? - Where exactly did you set
PREFECT_RUNNER_HEARTBEAT_FREQUENCY
, and what value?