{"id":26678268,"url":"https://github.com/telexintegrations/cloudflare-cdn-latency-alerts","last_synced_at":"2025-07-01T14:32:06.003Z","repository":{"id":278974924,"uuid":"937359119","full_name":"telexintegrations/cloudflare-cdn-latency-alerts","owner":"telexintegrations","description":"An integration that monitors Cloudflare's CDN response time and geo-specific latency issues.","archived":false,"fork":false,"pushed_at":"2025-02-25T20:27:26.000Z","size":30,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-26T05:15:19.365Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/telexintegrations.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-22T22:04:56.000Z","updated_at":"2025-02-25T20:27:30.000Z","dependencies_parsed_at":"2025-02-22T23:31:34.120Z","dependency_job_id":null,"html_url":"https://github.com/telexintegrations/cloudflare-cdn-latency-alerts","commit_stats":null,"previous_names":["telexintegrations/cloudflare-cdn-latency-alerts"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/telexintegrations/cloudflare-cdn-latency-alerts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telexintegrations%2Fcloudflare-cdn-latency-alerts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telexintegrations%2Fcloudflare-cdn-latency-alerts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telexintegrations%2Fcloudflare-cdn-latency-alerts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telexintegrations%2Fcloudflare-cdn-latency-alerts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/telexintegrations","download_url":"https://codeload.github.com/telexintegrations/cloudflare-cdn-latency-alerts/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telexintegrations%2Fcloudflare-cdn-latency-alerts/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262981106,"owners_count":23394466,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-26T05:15:19.424Z","updated_at":"2025-07-01T14:32:05.974Z","avatar_url":"https://github.com/telexintegrations.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cloudflare CDN Latency Alerts Integration\n\n## 📚 **Overview**\n\nThe **Cloudflare CDN Latency Alerts** integration is an **output integration** designed for the **Telex** platform. It continuously **monitors Cloudflare CDN response times** and identifies **geo-specific latency issues** using the **Cloudflare GraphQL Analytics API**. The integration helps teams to detect performance degradations at specific Cloudflare data centers (co locations) and receive timely alerts.\n\n---\n\n## 🚀 **Key Features**\n\n- 🌐 **Geo-Specific Latency Monitoring**: Tracks latency by city (`coloCity`) for Cloudflare points of presence (PoPs).\n- 📊 **Daily Aggregated Metrics**: Fetches daily metrics for HTTP requests and response times.\n- 💬 **Flexible Output Channels**: Supports easy integration with platforms like **Slack**, **email**, or custom webhooks.\n- 🔒 **Secure Authentication**: Uses **Cloudflare API Tokens** for secure access to analytics data.\n\n---\n\n## 🏗 **Integration Architecture**\n\n- **Framework**: `Node.js` with `Express.js`\n- **Language**: `TypeScript`\n- **Cloud Service**: `Cloudflare Analytics API`\n- **Platform**: `Telex (Output Integration)`\n\n---\n\n## 🔧 **Prerequisites**\n\n1. **Node.js** (v16+ recommended) and **npm** installed.\n2. **Cloudflare API Token** with permissions to access analytics data.\n3. A valid **Cloudflare Zone ID**.\n4. **Telex** account for integration deployment.\n\n---\n\n## ⚡ **Installation**\n\n### 1. **Clone the Repository:**\n```bash\ngit clone https://github.com/telexintegrations/cloudflare-cdn-latency-alerts.git\ncd cloudflare-cdn-latency-alerts\n```\n\n### 2. **Install Dependencies:**\n```bash\nnpm install\n```\n\n### 3. **Environment Configuration:**\nCreate a `.env` file in the root directory:\n```dotenv\nCLOUDFLARE_API_KEY=your_cloudflare_api_token_key\nCLOUDFLARE_ZONE_ID=your_cloudflare_zone_id\nTELEX_WEBHOOK_URL=your_telex_webhook_url\n```\n\n---\n\n## 🏃 **Running the Integration**\n\n### **Development Mode (with hot-reloading):**\n```bash\nnpm run dev\n```\n\n### **Production Mode:**\n```bash\nnpm run build\nnpm start\n```\n\nThe server will start at `http://localhost:3000` (or the port defined in `src/app.ts`).\n\n---\n\n## 🔌 **Telex Integration Settings**\n\nConfigure your **Telex** integration settings by adding the following in your `integration.json`:\n\n```json\n{\n  \"name\": \"Cloudflare CDN Latency Alerts\",\n  \"type\": \"output\",\n  \"category\": \"cloud services\",\n  \"description\": \"Monitors Cloudflare CDN response times and geo-specific latency issues using the Cloudflare Analytics API.\",\n  \"settings\": {\n    \"Cloudflare API Token\": \"{{CLOUDFLARE_API_TOKEN}}\",\n    \"Cloudflare Account ID\": \"{{CLOUDFLARE_ACCOUNT_ID}}\",\n    \"Telex Webhook URL\": \"{{TELEX_WEBHOOK_URL}}\",\n  }\n}\n```\n\n---\n\n## ⏰ **Cron Scheduling**\n\nThis integration uses **node-cron** for periodic checks:\n\n- **Hourly Schedule Example:**\n```typescript\nimport cron from 'node-cron';\ncron.schedule('0 * * * *', () =\u003e {\n  console.log('🔄 Running hourly latency check...');\n  checkLatencyAndAlert();\n});\n```\n- The `0 * * * *` cron expression runs **hourly** at minute zero.\n\n---\n\n## 📡 **Cloudflare Analytics API Query**\n\nThe integration sends a **GraphQL query** to fetch latency data:\n\n```graphql\nquery {\n    viewer {\n      zones(filter: { zoneTag: \"${CLOUDFLARE_ZONE_ID}\" }) {\n        httpRequests1dGroups(limit: 1, filter: { date_geq: \"2025-02-25\", date_leq: \"2025-02-26\" }) {\n          sum {\n            countryMap {\n              clientCountryName\n              requests\n            }\n            bytes\n            cachedBytes\n            requests\n            cachedRequests\n          }\n          dimensions {\n            date\n          }\n        }\n      }\n    }\n  }\n`;\n```\n\n- **`clientCountryName`**: City where Cloudflare PoP is located.\n- **`requests`**: Total number of requests processed.\n\n\n---\n\n## 🛠 **Testing the Integration**\n\n### ✅ **Unit Tests:**\n```bash\nnpm run test\n```\n\n## 🎨 **Project Structure**\n\n```\ncloudflare-cdn-latency-alerts/\n├── src/\n│   └── app.ts\n├── .gitignore\n├── LICENSE\n├── README.md\n├── integrationSpec.json\n├── package-lock.json\n├── package.json\n└── tsconfig.json\n```\n\n---\n\n## 📝 **Contributing**\n\n1. 🍴 Fork the repository.\n2. 💡 Create your feature branch: `git checkout -b feature/YourFeatureName`\n3. 💾 Commit your changes: `git commit -m 'Add YourFeatureName'`\n4. 📤 Push to the branch: `git push origin feature/YourFeatureName`\n5. 🔄 Submit a **Pull Request**.\n\n---\n\n## 🛡 **Security Considerations**\n\n- Use **API tokens** with **minimum required scopes**.\n- Secure `.env` files and avoid committing them to version control.\n- Validate incoming webhook payloads if integrating with third-party platforms.\n\n---\n\n## 📜 **License**\n\nThis project is licensed under the **MIT License**.\n\n---\n\n## 🙋 **Support \u0026 Feedback**\n\n- For issues, open a ticket in the **GitHub Issues** section.\n- For discussions and feature requests, open a **GitHub Discussion**.\n\n**Thank you 🚀🌐**","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelexintegrations%2Fcloudflare-cdn-latency-alerts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftelexintegrations%2Fcloudflare-cdn-latency-alerts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelexintegrations%2Fcloudflare-cdn-latency-alerts/lists"}