https://prefect.io logo
c

Constantino Schillebeeckx

02/02/2022, 3:36 PM
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

Zanie

02/02/2022, 3:53 PM
Yep! The agent hosts a healthcheck API
a

Anna Geller

02/02/2022, 3:58 PM
@Marvin archive “How can I programmatically check whether Prefect agent is healthy?”
c

Constantino Schillebeeckx

02/02/2022, 3:59 PM
very cool 🙂
z

Zanie

02/02/2022, 4:00 PM
Note you can also provide the address via the CLI with
--agent-address TEXT
c

Constantino Schillebeeckx

02/02/2022, 4:09 PM
Could you give some hints on what the address might be? We have an ECS agent running as a Fargate task.
z

Zanie

02/02/2022, 4:10 PM
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

Constantino Schillebeeckx

02/02/2022, 4:14 PM
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

Zanie

02/02/2022, 4:15 PM
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

Constantino Schillebeeckx

02/02/2022, 4:18 PM
Even easier! Thanks so much
6 Views