Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit 8db8d3b

Browse files
Add a new API metrics-lifecycle-policies (#21)
* patch(api) initial version of MLP API Signed-off-by: hayk96 <hayko5999@gmail.com> * feat: add background task support / fix metrics-lifecycle-policies API Signed-off-by: hayk96 <hayko5999@gmail.com> * chore: bump app version Signed-off-by: hayk96 <hayko5999@gmail.com> * docs(examples): add new flag in container args Signed-off-by: hayk96 <hayko5999@gmail.com> * Update CHANGELOG.md #minor Signed-off-by: hayk96 <hayko5999@gmail.com> --------- Signed-off-by: hayk96 <hayko5999@gmail.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent c6d6a6b commit 8db8d3b

18 files changed

+680
-9
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 0.3.0 / 2024-05-26
4+
5+
* [ENHANCEMENT]
6+
Introduced a new API `/metrics-lifecycle-policies` for managing metrics lifecycle in the Prometheus ecosystem. This
7+
flexible API allows users to define policies that specify which time-series should be retained and for how long in the
8+
Prometheus TSDB storage.
9+
* [BUGFIX] fixed description of 404 status code of the `DELETE /api/v1/rules` API in the Redocli page.
10+
311
## 0.2.2 / 2024-05-12
412

513
* [REVERT] Reverted schema validation mechanism of rules API. Use local schema validation instead of remote which was introduces in [v0.1.2](https://github.com/hayk96/prometheus-api/releases/tag/v0.1.2). #18

docs/examples/docker/docker-compose.yml

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ services:
1111
command:
1212
- --config.file=/etc/prometheus/prometheus.yml
1313
- --web.enable-lifecycle
14+
- --web.enable-admin-api
1415
prometheus-api:
1516
image: hayk96/prometheus-api:latest
1617
container_name: prometheus-api

docs/examples/kubernetes/helm/values.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ server:
1717
readOnly: false
1818
extraFlags:
1919
- web.enable-lifecycle
20+
- web.enable-admin-api
2021
- web.listen-address=:9091
2122
extraVolumeMounts:
2223
- name: storage-volume

main.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from fastapi.middleware.cors import CORSMiddleware
22
from src.utils.arguments import arg_parser
3+
from src.utils.scheduler import schedule
34
from src.api.v1.api import api_router
45
from src.utils.openapi import openapi
56
from src.utils.metrics import metrics
@@ -15,9 +16,9 @@
1516
host, port = args.get("web.listen_address").split(":")
1617

1718
if not all([settings.check_prom_http_connection(prom_addr),
18-
settings.check_reload_api_status(prom_addr),
19-
settings.check_rules_directory(rule_path),
20-
settings.check_fs_permissions(rule_path)]):
19+
settings.check_reload_api_status(prom_addr),
20+
settings.check_rules_directory(rule_path),
21+
settings.check_fs_permissions(rule_path)]):
2122
sys.exit()
2223

2324

@@ -56,4 +57,5 @@ def main():
5657

5758

5859
if __name__ == "__main__":
60+
schedule()
5961
main()

requirements.txt

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
prometheus-fastapi-instrumentator==6.1.0
22
python-json-logger==2.0.7
33
email-validator==2.0.0
4-
fastapi==0.109.0
5-
uvicorn==0.21.1
4+
APScheduler==3.10.4
5+
pytimeparse2==1.7.1
6+
jsonschema==4.17.3
67
requests==2.28.2
78
pydantic==1.10.7
9+
fastapi==0.109.0
10+
uvicorn==0.21.1
811
PyYAML==6.0.1
9-
jsonschema==4.17.3
1012
httpx==0.24.0

src/api/v1/api.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
from .. v1.endpoints import reverse_proxy, rules, web
1+
from .. v1.endpoints import reverse_proxy, rules, policies, web
22
from fastapi import APIRouter
33

44
api_router = APIRouter()
55
api_router.include_router(rules.router, prefix="/api/v1")
6+
api_router.include_router(policies.router, prefix="/api/v1")
67
api_router.include_router(web.router, prefix="")
78
api_router.add_route("/{path:path}", reverse_proxy._reverse_proxy, ["GET", "POST", "PUT"])

0 commit comments

Comments
 (0)