{"id":24493048,"url":"https://github.com/numberly/typesense_exporter","last_synced_at":"2025-07-02T08:33:40.168Z","repository":{"id":270294157,"uuid":"908618910","full_name":"numberly/typesense_exporter","owner":"numberly","description":"A prometheus exporter for Typesense","archived":false,"fork":false,"pushed_at":"2025-06-10T08:32:59.000Z","size":38,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-14T03:04:25.056Z","etag":null,"topics":["exporter","prometheus","search","typesense"],"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/numberly.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,"zenodo":null}},"created_at":"2024-12-26T14:17:46.000Z","updated_at":"2025-03-14T14:16:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"8114d0b4-ba9b-4fde-9d80-22bab94c9e85","html_url":"https://github.com/numberly/typesense_exporter","commit_stats":null,"previous_names":["numberly/typesense_exporter"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/numberly/typesense_exporter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numberly%2Ftypesense_exporter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numberly%2Ftypesense_exporter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numberly%2Ftypesense_exporter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numberly%2Ftypesense_exporter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/numberly","download_url":"https://codeload.github.com/numberly/typesense_exporter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numberly%2Ftypesense_exporter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259752050,"owners_count":22905970,"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":["exporter","prometheus","search","typesense"],"created_at":"2025-01-21T19:18:59.574Z","updated_at":"2025-06-14T03:05:27.137Z","avatar_url":"https://github.com/numberly.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Typesense Prometheus Exporter (On-Demand Fetch)\n\nA **Prometheus** exporter that queries a [Typesense](https://typesense.org/) cluster on-demand each time Prometheus scrapes the `/metrics` endpoint. This ensures that the data is always **fresh** and eliminates the need for a separate polling loop.\n\n## Key Features\n\n- **On-Demand Scraping**: Data is fetched live from Typesense whenever Prometheus scrapes.\n- **Easy Configuration**: Set options via environment variables or command-line arguments.\n- **Collections**: Exposes per-collection document counts.\n- **Automatic SSL Verification Control**: Optionally disable SSL cert verification for development or when using self-signed certs.\n\n## Usage\n\n1. Clone or copy the script into your environment.\n\n2. Install Dependencies:\n\n```bash\npip install -r requirements.txt\n```\n\n3. Run the Exporter:\n\n```bash\n./typesense_exporter.py --port 8000 \\\n  --typesense-api-key \"YOUR_API_KEY\" \\\n  --typesense-nodes \"host1:8108,host2:8108\"\n```\n\nOr rely on environment variables:\n\n```bash\nexport TYPESENSE_API_KEY=\"YOUR_API_KEY\"\nexport TYPESENSE_NODES=\"host1:8108,host2:8108\"\n./typesense_exporter.py\n```\n\n4. Scrape with Prometheus:\n\nAdd to your Prometheus `prometheus.yml`:\n\n```yaml\nscrape_configs:\n  - job_name: \"typesense_exporter\"\n    static_configs:\n      - targets: [\"localhost:8000\"]\n```\n\n5. Verify\n\nNavigate to http://localhost:8000/metrics in your browser or use `curl http://localhost:8000/metrics` to see the exposed metrics.\n\n## Command-Line Arguments\n\n| Argument                  | Env Var                 | Default                               | Description                                                                                        |\n| ------------------------- | ----------------------- | ------------------------------------- | -------------------------------------------------------------------------------------------------- |\n| `--typesense-api-key`     | `TYPESENSE_API_KEY`     | _(none)_                              | Your Typesense API key.                                                                            |\n| `--typesense-metrics-url` | `TYPESENSE_METRICS_URL` | `https://localhost:8108/metrics.json` | The full URL to `metrics.json` endpoint.                                                           |\n| `--typesense-stats-url`   | `TYPESENSE_STATS_URL`   | `https://localhost:8108/stats.json`   | The full URL to `stats.json` endpoint.                                                             |\n| `--typesense-debug-url`   | `TYPESENSE_DEBUG_URL`   | `https://localhost:8108/debug`        | The full URL to `stats.json` endpoint.                                                             |\n| `--typesense-nodes`       | `TYPESENSE_NODES`       | `localhost:8108`                      | A comma-separated list of `host:port` entries for Typesense nodes (e.g., `node1:8108,node2:8108`). |\n| `--verify`                | `VERIFY_SSL`            | `False`                               | Verify SSL certificates. Set `--verify` to enable, or `VERIFY_SSL=true` for environment.           |\n| `--port`                  | _(not applicable)_      | `8000`                                | Which port the exporter will listen on for Prometheus scrapes.                                     |\n\n\u003e **Tip**: Command-line arguments override environment variables, which override the defaults.\n\n## How It Works\n\n- The script registers a custom TypesenseCollector with Prometheus.\n- Every time Prometheus sends a GET request to /metrics:\n  - The collector fetches /metrics.json, /stats.json, and the list of collections from the configured Typesense node(s).\n  - Each field is converted to a Prometheus metric and yielded dynamically.\n\nThis design guarantees that metrics are always up-to-date at scrape time (with no in-memory caching or stale metrics).\n\n## Customization\n\n- Modify `_collect_metrics_json` or `_collect_stats_json` to handle additional fields or parse additional endpoints as needed.\n- Adjust `_sanitize_metric_name` if you want to add or remove transformations for metric names.\n- Wrap the exporter in Docker or a systemd service to manage it in production environments.\n\n## License\n\nThis exporter is released under the MIT License. See LICENSE for details (or replace with your preferred license).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnumberly%2Ftypesense_exporter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnumberly%2Ftypesense_exporter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnumberly%2Ftypesense_exporter/lists"}