[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. 🫖 Status page with uptime monitoring & API monitoring as code 🫖 openstatus.dev
README.md
# Export Blog Post Metrics Script This script exports monitor metrics data from OpenStatus for use in blog posts and documentation. ## Overview The script fetches monitor data directly from the database and Tinybird analytics, then exports it to a JSON file that can be used for visualizations in blog posts. **Features:** - Fetches metrics from both regular regions and private locations - Automatically combines public regions with private location data - Supports both HTTP and TCP monitors ## Configuration Edit the constants at the top of `export-blog-post-metrics.ts`: ```typescript const MONITOR_ID = "1"; // The ID of the monitor to export const PERIOD = "7d"; // Time period: "1d", "7d", or "14d" const INTERVAL = 60; // Interval in minutes for data points const TYPE = "http"; // Fallback monitor type: "http" or "tcp" (auto-detected from monitor) const OUTPUT_FILE = "blog-post-metrics.json"; // Output filename ``` **Note:** The script automatically detects the monitor type from the database, but you can set a fallback with the `TYPE` constant. ## Prerequisites 1. Make sure you have the `TINY_BIRD_API_KEY` environment variable set in your `.env` file 2. The database should be accessible (local or remote) 3. Install dependencies: `pnpm install` ## Usage > [!IMPORTANT] > Go to the `/tinybird/src/client.ts` file and make sure tb is **not using the NoopClient**. From the `apps/dashboard` directory: ```bash # Using the npm script pnpm export-metrics # Or directly with bun bun src/scripts/export-blog-post-metrics.ts ``` ## Output Format The script generates a JSON file with the following structure: ```json { "regions": ["ams", "fra", "lhr", ...], "data": { "regions": ["ams", "fra", "lhr", ...], "data": [ { "timestamp": "2025-08-18T16:00:00.000Z", "ams": 207, "fra": 142, "lhr": 327, ... } ] }, "metricsByRegions": [ { "region": "ams", "count": 1000, "ok": 995, "p50Latenc…