is there some sort of API endpoint that we can hit...
# ask-community
c
is there some sort of API endpoint that we can hit which serves as a health check? I'm wondering how I can programmatically check that the agent is healthy
z
Yep! The agent hosts a healthcheck API
a
@Marvin archive “How can I programmatically check whether Prefect agent is healthy?”
c
very cool 🙂
z
Note you can also provide the address via the CLI with
--agent-address TEXT
c
Could you give some hints on what the address might be? We have an ECS agent running as a Fargate task.
z
The address is empty by default
You’ll need to set the environment variable for the config or change the command the task runs. e.g.
Copy code
prefect agent local start --agent-address <http://0.0.0.0:5000/>
Copy code
❯ curl <http://localhost:5000/api/health>
{}%
c
That makes sense for the local case; but when my agent is hosted on ECS (as a Fargate task) I imagine I can't just set the address to anything?
z
0.0.0.0 binds to all incoming connections so you could then perform a healthcheck at whatever the IP of your task is
That’d be determined by AWS networking, which I can’t help you with 🙂 in that case, you can check the agent’s last query time by hitting the server’s GraphqQL API instead
e.g.
<https://cloud.prefect.io/api?query={%0Aagent{%0A%20> id%0A%20 last_queried%0A}}
c
Even easier! Thanks so much