Uptime is a lightweight, serverless monitoring service built on Cloudflare Workers. It runs on a cron schedule, performs a configurable list of health checks, stores the latest state in Workers KV, and sends Telegram alerts on downtime and recovery. Optionally, it can sync component status to Statuspage.io.
- Active Monitoring: Periodically checks the availability of configured targets.
- Serverless: Runs on Cloudflare Workers with minimal infrastructure overhead.
- Telegram Alerts: Sends notifications that dynamically update to accurately reflect the current state of all checks.
- Statuspage Sync (Optional): Maps each check to a Statuspage component and updates its status.
- Zero Trust Support: Works with sites behind Cloudflare Zero Trust via client credentials.
- Configure a list of checks in
uptime.config.ts. - A scheduled Cloudflare Worker runs on a cron defined in
packages/uptime-worker/wrangler.jsonc. - Each check is performed; results are stored in Workers KV (state + last-checked timestamp).
- If any check fails, a Telegram alert is sent and subsequently updated to accurately reflect the state of all checks until full recovery.
- If Statuspage.io credentials are configured, each check is synced to a Statuspage component.
- Cloudflare Workers
- Workers KV
- Wrangler for development and deployment
- TypeScript
- Telegram Bot API (via grammy)
- LiquidJS for template parsing
- Statuspage API (optional)
- GitHub Actions (optional deployment)
-
Clone the repository:
git clone https://github.com/hobroker/uptime.git cd uptime -
Run the interactive setup:
npm install npm run setup
This script will help you:
- Login to Cloudflare.
- Create the required KV namespace and update your configuration.
- Set up your Telegram and optional Statuspage secrets.
- Prepare your local environment.
-
Configure your monitors: Edit
packages/uptime-worker/uptime.config.ts. Here's a basic example:export const uptimeWorkerConfig: UptimeWorkerConfig = { checks: [ { name: "My Website", target: "https://example.com", retryCount: 2, }, { name: "API Health", target: "https://api.example.com/health", method: "GET", expectedCodes: [200], }, ], };
-
Deploy:
npm run deploy
- A Cloudflare account.
- A Telegram bot and a chat for notifications.
If you prefer to set up everything manually, follow these steps:
- KV Namespace: Create a KV namespace named
uptimeand add its ID topackages/uptime-worker/wrangler.jsonc. - Secrets: Use
npx wrangler secret putforTELEGRAM_BOT_TOKEN,TELEGRAM_CHAT_ID, and other optional credentials. - Local Vars: Copy
packages/uptime-worker/.dev.vars.exampletopackages/uptime-worker/.dev.varsand fill in the values.
To enable automatic deployments from GitHub Actions, you'll need to set up a Cloudflare API token:
- Generate a Cloudflare API token by following the instructions at: https://developers.cloudflare.com/fundamentals/api/get-started/create-token/
- Add the token as a GitHub repository secret:
- Go to your GitHub repository
- Navigate to Settings > Secrets and variables > Actions
- Click New repository secret
- Name:
CLOUDFLARE_API_TOKEN - Value: Your generated Cloudflare API token
- Name:
- The GitHub Actions workflow will automatically deploy your changes when you push to the main branch.
- Install dependencies:
npm install
- Setup environment:
Run the interactive setup to automatically create your
.dev.varsfile and generate types:npm run setup
- Start development server:
npm run dev
- Test the worker locally:
Uptime uses Cloudflare Cron Triggers. You can simulate a cron event locally by calling the
/__scheduledendpoint:curl "http://localhost:8787/__scheduled?cron=*+*+*+*+*"
Once deployed, Uptime will automatically run on the configured cron schedule, perform the checks in uptime.config.ts, and send Telegram notifications based on state changes.
Contributions are welcome! Please feel free to submit issues or pull requests.
- Check types:
npm run ts-check - Lint:
npm run lint - Format:
npm run format - Test:
npm run test
Before submitting a PR, please ensure all the above checks pass. We use Turbo to manage the monorepo, so these commands will run across all packages.
This project is licensed under the MIT License. See the LICENSE file for details.