{"id":39149994,"url":"https://github.com/amallek/prometheus-api","last_synced_at":"2026-01-17T21:39:00.141Z","repository":{"id":204953162,"uuid":"712825919","full_name":"amallek/prometheus-api","owner":"amallek","description":"Lightweight Prometheus API serves as a powerful tool for managing your Prometheus configuration remotely","archived":false,"fork":false,"pushed_at":"2024-11-06T20:23:06.000Z","size":13,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-26T01:57:13.790Z","etag":null,"topics":["api","automation","prometheus","rest","rest-api","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/amallek.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2023-11-01T09:26:38.000Z","updated_at":"2024-11-07T00:32:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"f3ba32da-fab7-403f-8fc1-43234f748d43","html_url":"https://github.com/amallek/prometheus-api","commit_stats":{"total_commits":4,"total_committers":1,"mean_commits":4.0,"dds":0.0,"last_synced_commit":"cdb7d5e52fafefd1720c85678b81fc668ebb9948"},"previous_names":["amallek/prometheus-api"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/amallek/prometheus-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amallek%2Fprometheus-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amallek%2Fprometheus-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amallek%2Fprometheus-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amallek%2Fprometheus-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amallek","download_url":"https://codeload.github.com/amallek/prometheus-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amallek%2Fprometheus-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28518648,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T18:55:29.170Z","status":"ssl_error","status_checked_at":"2026-01-17T18:55:03.375Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["api","automation","prometheus","rest","rest-api","rust"],"created_at":"2026-01-17T21:38:59.663Z","updated_at":"2026-01-17T21:39:00.133Z","avatar_url":"https://github.com/amallek.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Prometheus API\n\n\n## Overview\nLightweight Prometheus API serves as a powerful tool for managing your Prometheus configuration remotely. This code was developed as part of one of our latest projects, and I've decided to publish it because I find it incredibly useful. Written in Rust, the project offers basic authentication and various API endpoints for versatile management of your Prometheus setup.\n\n## Features\n\n- **Flexible Endpoints**: Numerous API calls available for managing Prometheus settings.\n- **Basic Authentication**: Secure your Prometheus configurations with a configurable `x-auth` token.\n- **Rust-powered**: Built with the speed and safety of Rust.\n\n## Prerequisites\n\n- Rust (latest stable version)\n- Prometheus installed and running\n\n## Getting started\n\nTo get started, follow the instructions below.\n\n##### Step 1 - Clone this repository\n\n```shell\ngit clone https://github.com/amallek/prometheus-api.git\n```\n##### Step 2 - Navigate to the project directory\n\n```shell\ncd prometheus-api\n```\n\n##### Step 3 - Build the project\n```shell\n# Uncomment the next line if Rust is not installed\n# curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh\ncargo build --release\n```\n\n##### Step 4 - Run the application\n```shell\n# Uncomment to generate self-signed TLS certs\n# ./helpers/create-cert.sh\n./target/release/prometheus-api\n```\n\n##### Step 5 - Install as a service (optional)\n\nIf desired, you can install prometheus-api as a service. An example script is available in helpers/create-service.sh.\n\n```shell\n# Uncomment the next line to execute the script\n# ./helpers/create-service.sh\nsystemctl start prometheus-api\n```\n\n\n## 🛠 API Endpoints\n\nThe API provides a range of functionalities through the following endpoints:\n\n### `prometheus::info()`\n\n- **Endpoint**: `GET /info`\n- **Description**: Retrieves basic information about the Prometheus API \n- **Authentication**: Required (`x-auth` token)\n  \n### `prometheus::config_get()`\n\n- **Endpoint**: `GET /config`\n- **Description**: Fetches the current `prometheus.yml` configuration in JSON format.\n- **Authentication**: Required (`x-auth` token)\n\n### `prometheus::endpoint_get()`\n\n- **Endpoint**: `GET /endpoint/{endpoint}`\n- **Description**: Obtains details about a specified Prometheus scraping endpoint.\n- **Authentication**: Required (`x-auth` token)\n\n### `prometheus::endpoint_add()`\n\n- **Endpoint**: `PUT /endpoint`\n- **Description**: Adds a new scraping endpoint to the Prometheus configuration.\n- **Payload**: JSON object with endpoint details.\n- **Authentication**: Required (`x-auth` token)\n\n### `prometheus::endpoint_delete()`\n\n- **Endpoint**: `DELETE /endpoint/{endpoint}`\n- **Description**: Removes a specified scraping endpoint from the Prometheus configuration.\n- **Authentication**: Required (`x-auth` token)\n\n### `prometheus::endpoint_update()`\n\n- **Endpoint**: `POST /endpoint`\n- **Description**: Updates an existing scraping endpoint in the Prometheus configuration.\n- **Payload**: JSON object with updated endpoint details.\n- **Authentication**: Required (`x-auth` token)\n\nThe payload required consists of literally what you would see in the prometheus.yaml file, but JSON encoded. For instance:\n\n##### Add\n\n```shell\ncurl -ikX PUT \\\n    'https://localhost:9090/endpoint' \\\n    -H 'x-auth: my_password' \\\n    -d '{\n \"job_name\": \"my-job-name\",\n \"scrape_interval\": \"60\",\n \"scrape_timeout\": \"5\",\n \"scheme\": \"https\",\n \"static_configs\": [\n    {\n        \"targets\": [\"my.machine.example.com:9091\"],\n        \"labels\": {\"label1\":\"val\",\"label2\":\"val\"}\n    }\n ]\n}'\n#{\"success\":true}\n```\n\n##### Get\n\n```shell\ncurl -ik 'https://localhost:9090/endpoint/my-job-name' \\\n    -H 'x-auth: my_password'\n```\n\n##### Remove\n\n```shell\ncurl -ikX DELETE \\\n    'https://localhost:9090/endpoint/my-job-name' \\\n    -H 'x-auth: my_password'\n```\n\n## Authentication\n\nInclude an `x-auth` token in every API call to ensure authentication. The token can be updated or replaced by custom logic in the `verify_token()` method (see `src/security.rs`).\n\n## License\n\nThis project is licensed under the terms of the MIT License (see LICENSE.)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famallek%2Fprometheus-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famallek%2Fprometheus-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famallek%2Fprometheus-api/lists"}