{"id":27261509,"url":"https://github.com/maniam/grafana-betterstack-proxy","last_synced_at":"2026-04-29T00:33:40.420Z","repository":{"id":287124071,"uuid":"963676791","full_name":"ManiAm/grafana-betterstack-proxy","owner":"ManiAm","description":"A lightweight REST API proxy that connects BetterStack monitoring data to Grafana using JSON endpoints compatible with the Infinity plugin.","archived":false,"fork":false,"pushed_at":"2025-04-10T04:04:27.000Z","size":0,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-10T04:36:11.934Z","etag":null,"topics":["betterstack","grafana","python","rest-api"],"latest_commit_sha":null,"homepage":"","language":"Python","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/ManiAm.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-04-10T03:38:56.000Z","updated_at":"2025-04-10T04:09:39.000Z","dependencies_parsed_at":"2025-04-10T04:36:14.257Z","dependency_job_id":"07537cf3-52ed-4bc5-9428-d023c9d1504e","html_url":"https://github.com/ManiAm/grafana-betterstack-proxy","commit_stats":null,"previous_names":["maniam/grafana-betterstack-proxy"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ManiAm%2Fgrafana-betterstack-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ManiAm%2Fgrafana-betterstack-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ManiAm%2Fgrafana-betterstack-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ManiAm%2Fgrafana-betterstack-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ManiAm","download_url":"https://codeload.github.com/ManiAm/grafana-betterstack-proxy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248347839,"owners_count":21088750,"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":["betterstack","grafana","python","rest-api"],"created_at":"2025-04-11T05:33:38.901Z","updated_at":"2026-04-29T00:33:40.415Z","avatar_url":"https://github.com/ManiAm.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BetterStack REST Proxy for Grafana\n\nThis project provides a lightweight Python-based REST server that proxies monitoring data from [BetterStack](https://betterstack.com) and exposes it in a Grafana-friendly format. It enables Grafana to visualize website response times and availability metrics using the Infinity plugin or other JSON-compatible data sources.\n\n---\n\n## Features\n\n- REST API endpoint to serve BetterStack uptime and SLA data\n- Supports multiple regions (US, EU, AS, AU)\n- Timestamp conversion to Unix milliseconds (Grafana-compatible)\n- Query filtering by node hostname\n\n---\n\n## Getting Started\n\n### Prerequisites\n- Python 3.7+\n- A BetterStack API token\n- Grafana with the [Infinity plugin](https://grafana.com/grafana/plugins/yesoreyeram-infinity-datasource/)\n\n### Install Dependencies\n```bash\npip install flask flask-compress requests\n```\n\n### Set Environment Variable\n```bash\nexport BetterStack_API_TOKEN=your_betterstack_token\n```\n\n### Run the Server\n```bash\npython3 grafana_server.py\n```\n\nThe server will be available at `http://\u003cyour_host\u003e:5006`\n\n---\n\n## Available Endpoints\n\n### `GET /response_time`\nReturns response time data per region.\n\n**Query parameters:**\n- `nodename`: hostname to match the node\n- `url`: monitored website URL\n- `region`: comma-separated list of regions (default: `us,eu,as,au`)\n\n**Sample response:**\n```json\n[\n  {\n    \"timestamp\": 1744539757000,\n    \"region\": \"us\",\n    \"response_time\": 0.47273\n  },\n]\n```\n\n---\n\n### `GET /sla`\nReturns website availability (SLA) data.\n\n**Query parameters:**\n- `nodename`: hostname to match the node\n- `url`: monitored website URL\n\n**Sample response:**\n```json\n{\n  \"availability\": 99.97\n}\n```\n\n---\n\n## Run as a systemd Service\n\nTo run the project in the background and start it on system boot:\n\n1. Copy the service file:\n```bash\nsudo cp grafana-betterstack.service /etc/systemd/system/grafana-betterstack.service\n```\n\n2. Reload systemd and start the service:\n\n```bash\nsudo systemctl daemon-reexec\nsudo systemctl daemon-reload\nsudo systemctl enable grafana-betterstack\nsudo systemctl start grafana-betterstack\n```\n\n3. Check status and logs:\n\n```bash\nsudo systemctl status grafana-betterstack\n```\n\n4. On service failure check the journal logs:\n\n```bash\njournalctl -u grafana-betterstack -n 50 --no-pager\n```\n\nEnsure that your virtual environment and script paths are correctly set in the service file.\n\n---\n\n## Architecture\n\nThe server uses the `UPTIME_REST_API_Client` class to interact with BetterStack's API:\n- Fetch monitor ID by URL\n- Retrieve response time history\n- Retrieve SLA/availability metrics\n\nThe `Flask` app exposes data as Grafana-friendly JSON endpoints.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaniam%2Fgrafana-betterstack-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaniam%2Fgrafana-betterstack-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaniam%2Fgrafana-betterstack-proxy/lists"}