# Webhooks for machine states?

**URL:** <https://community.fly.io/t/webhooks-for-machine-states/23385>\
**Category:** General\
**Tags:** metrics, machines, login-only\
**Created:** [January 8, 2025, 11:30pm UTC](https://community.fly.io/t/webhooks-for-machine-states/23385 "2025-01-08T23:30:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![punkpeye](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/punkpeye/32/39218_2.png) [@punkpeye](https://community.fly.io/u/punkpeye)\
**Post date:** [January 8, 2025, 11:30pm UTC](https://community.fly.io/t/webhooks-for-machine-states/23385/1 "2025-01-08T23:30:29Z")

</div>

I am looking for a solution that would allow me to track when the machines are running, suspended, etc.

I am building a hosting service on top of Fly and this is needed to accurately bill the end customers.

As I don’t see any mention in the documentation, any solutions?

Using API to poll is non-viable due to rate limits as there will be thousands of machines.

---

<div class="post-metadata">

**Author:** ![punkpeye](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/punkpeye/32/39218_2.png) [@punkpeye](https://community.fly.io/u/punkpeye)\
**Post date:** [January 9, 2025, 1:59am UTC](https://community.fly.io/t/webhooks-for-machine-states/23385/2 "2025-01-09T01:59:34Z")

</div>

I hacked something together using API, but yeah – it means hitting Fly API every few seconds.

---

<div class="post-metadata">

**Author:** ![punkpeye](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/punkpeye/32/39218_2.png) [@punkpeye](https://community.fly.io/u/punkpeye)\
**Post date:** [January 9, 2025, 2:24am UTC](https://community.fly.io/t/webhooks-for-machine-states/23385/3 "2025-01-09T02:24:04Z")

</div>

Found a semi decent solution.

If I increase the interval, and instead of checking the current state, I check the events associated with the machine, that works quite well. Just a lot more complicated logic.

---

<div class="post-metadata">

**Author:** ![kyleatcausadix](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/kyleatcausadix/32/18530_2.png) [@kyleatcausadix](https://community.fly.io/u/kyleatcausadix)\
**Post date:** [January 9, 2025, 2:39am UTC](https://community.fly.io/t/webhooks-for-machine-states/23385/4 "2025-01-09T02:39:16Z")

</div>

Your product might be eligible for the [Extensions Program](https://fly.io/docs/about/extensions/). If so, you’ll get access to [Outbound Webhooks](https://fly.io/docs/reference/extensions_api/#outbound-webhooks-get-notified-about-changes-to-provisioned-accounts-and-resources) which include machine state changes.

If you _don’t_ go that route, API polling and [direct Prometheus integration](https://fly.io/docs/monitoring/metrics/#prometheus-on-fly-io) are the two threads I’d pull on. Word of caution that Fly Metrics can be a bit rocky at times, so I would only suggest that interface for convenience and make sure you have a reconciliation plan for true-up.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/fly1/original/3X/6/e/6e8955d00cb218e186ebbe3a6ab06fefdce15290.svg) [@system](https://community.fly.io/u/system)\
**Post date:** [January 16, 2025, 2:40am UTC](https://community.fly.io/t/webhooks-for-machine-states/23385/5 "2025-01-16T02:40:03Z")

</div>

Closed on January 16, 2025, 2:40am UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
