Cloudflare Medivh: a self-hosted near-real-time bill estimator
An open-source, self-hosted monitor that adds today’s estimated usage cost to Cloudflare’s daily-updated billable usage, sends summaries, and calls a webhook when the current cycle crosses a budget.
- Products
- WorkersWorkers LogsWorkers BuildsContainersDurable ObjectsR2QueuesD1Workers KV
- Source
- Community resourceGitHub repository
- Author
- NPC_Jyy (@jinyang1994)
Key points
- The README says Cloudflare’s Billable Usage API updates daily and not exactly at 00:00 UTC, so intraday spikes are hard to notice. Medivh estimates the current cycle as the official cumulative cost through yesterday plus today’s estimated increment, retries the official sync after 00:00 UTC, and rechecks the last three days for late or revised charges.
- It collects every 10 minutes, can push summaries to a Feishu bot, and can call a budget webhook when the official-plus-estimate total strictly exceeds a threshold set in integer cents. The webhook fires once per billing cycle, only for USD cycles, and carries an Idempotency-Key.
- Stated limits: it only monitors, reconciles and notifies; it does not stop Cloudflare services and is not a hard cap. The author explains that stopping some services, such as Durable Objects, must be built into business logic, so only a webhook is exposed. Unit prices live in a local price table that does not follow official price changes, analytics can lag or be sampled, and Workers Logs history is limited to seven days.
- The token needs Account Billing Read and Account Analytics Read, plus Workers Observability Write because the log query API currently requires it. The dashboard has no built-in login, and the README says the project was mainly written by vibe coding.
Original sources
Last updated
Cloudflare Medivh: a self-hosted near-real-time bill estimator
Open original sourceAn open-source, self-hosted monitor that adds today’s estimated usage cost to Cloudflare’s daily-updated billable usage, sends summaries, and calls a webhook when the current cycle crosses a budget.
The author says he is preparing to open-source the bill monitoring and auto-disable service he uses.
Read on 𝕏NPC_Jyy
@jinyang1994 · Original 𝕏 post
我已经准备开源我用的监控账单自动停用服务了
The author writes that the bill available through the API only covers up to yesterday, so a real-time bill has to be calculated yourself.
Read on 𝕏NPC_Jyy
@jinyang1994 · Original 𝕏 post
赞同,主要恶心的在于API获取的账单只能是昨天的。 如果你想拿到实时账单,需要自己手动算... pic.twitter.com/tw7mmeWQ6T
Open-source announcement: the service calculates the bill in real time, sends it periodically, and calls a webhook when over the limit for emergency shutdown or phone alerts; the author hopes it helps before Cloudflare ships hard caps.
Read on 𝕏NPC_Jyy
@jinyang1994 · Original 𝕏 post
开源了一个Cloudflare账单监控服务。 可以实时计算账单,定期发送实时账单,超出限额调用webhook(用来实现紧急停用服务或电话通知)。 希望在Cloudflare发布账单硬顶功能前能帮助到大家。 欢迎大家试用,反馈不同场景下的问题,让系统健壮起来。 求扩散 @imwsl90https://t.co/27j21d0L38 https://t.co/qwS3k33VxS
Another author, M. (@wlzh), introduces Medivh as collecting every 10 minutes with Feishu summaries and a threshold webhook, and stresses that it only monitors and alerts; it does not stop services automatically and is not a hard cap.
Read on 𝕏M.
@wlzh · Original 𝕏 post
前几天一位老哥,Codex 的代码 bug 让他的项目在 Cloudflare 上一晚上刷掉一万多刀。 这事儿把另一位老哥吓得夜不能寐:自己的项目全搭在 Cloudflare 上,代码还都是 AI 写的,万一哪天睡觉的时候被刷破产了呢? 于是有人直接开源了一个 Cloudflare 账单监控服务,叫 Medivh(麦迪文,守护者+预警者的意思)。 干的事:近实时估算账单(官方接口一天才更新一次,等它黄花菜都凉了),每 10 分钟采集一次;定期推送账单汇总,支持飞书通知;费用超过你设的阈值就打 webhook,你可以接紧急停服或者电话告警。 先说清楚:它只监控和报警,不会自动帮你停服务,也不是账单硬顶。Cloudflare 官方说 2026 年 Q4 出费用硬顶功能,在那之前,先给自己的钱包加道保险。 作者自己说的:主要靠 vibe coding 写的,介意勿用。刚开源,但这种救命的工具,越早用上越好。
In a reply to a $500 D1 bill thread, the author says Cloudflare's billing dashboard does not show each day's total until the next day, so it cannot reveal problems in real time; cf-medivh estimates the current bill every ten minutes and alerts on unusual charges.
Read on 𝕏NPC_Jyy
@jinyang1994 · Original 𝕏 post
What makes matters worse is that Cloudflare’s billing dashboard doesn’t show each day’s total charges until the following day. This means we can’t use it to spot problems in real time. That’s why I created cf-medivh, an open-source project that estimates your current bill every ten minutes and quickly alerts you to unusual charges. I hope this project can help others, too. https://t.co/k49YXWiElI
Replying to @wquguru, the author repeats that official billing information updates only the next day and says cf-medivh estimates the bill in near real time to warn when a large bill is just starting.
Read on 𝕏NPC_Jyy
@jinyang1994 · Original 𝕏 post
@wquguru 而且最坑的是,就算你盯着cloudflare官方账单信息,它也是第二天才更新。 我开源了一个监控,它可以预估实时账单,在天价账单刚起步的时候就给你警告。 https://t.co/27j21d0L38
More to read
FlareMeter: Cloudflare usage in the macOS menu bar with early-warning alerts
Manish Rana's free, open-source (AGPL-3.0) macOS menu bar app and widgets show Workers, Durable Objects, KV, D1 and Workers AI usage against plan limits, estimate Workers Paid overage, and alert near limits, past a budget or on 10× spikes.
Cynthia Toporowski (@ItsCynnamoroll): Cloudflare bill inflated to around $400, well beyond expectations.
Cynthia Toporowski (@ItsCynnamoroll) says the Cloudflare bill inflated well beyond what was anticipated, to around $400, and that an AI coding agent was told to immediately scan for issues and rework the project’s git implementation so that billing runaway is not a concern going forward. The same post says the reworked implementation looks faster and cheaper than Cloudflare Artifacts.
Why hard spending caps take time: Ashley Peacock on billing latency
Ashley Peacock (@ashleypeacock), who works on Durable Objects at Cloudflare, explains from experience why near-real-time spending caps are hard to build, says hard billing caps are coming soon, and suggests budget alerts plus issue alerts in the meantime.