Skip to content

Commit

Permalink
Add a new API metrics-lifecycle-policies (#21)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
hayk96 and github-actions[bot] authored May 26, 2024
1 parent c6d6a6b commit 8db8d3b
Show file tree
Hide file tree
Showing 18 changed files with 680 additions and 9 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.3.0 / 2024-05-26

* [ENHANCEMENT]
Introduced a new API `/metrics-lifecycle-policies` for managing metrics lifecycle in the Prometheus ecosystem. This
flexible API allows users to define policies that specify which time-series should be retained and for how long in the
Prometheus TSDB storage.
* [BUGFIX] fixed description of 404 status code of the `DELETE /api/v1/rules` API in the Redocli page.

## 0.2.2 / 2024-05-12

* [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
Expand Down
1 change: 1 addition & 0 deletions docs/examples/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ services:
command:
- --config.file=/etc/prometheus/prometheus.yml
- --web.enable-lifecycle
- --web.enable-admin-api
prometheus-api:
image: hayk96/prometheus-api:latest
container_name: prometheus-api
Expand Down
1 change: 1 addition & 0 deletions docs/examples/kubernetes/helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ server:
readOnly: false
extraFlags:
- web.enable-lifecycle
- web.enable-admin-api
- web.listen-address=:9091
extraVolumeMounts:
- name: storage-volume
Expand Down
8 changes: 5 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from fastapi.middleware.cors import CORSMiddleware
from src.utils.arguments import arg_parser
from src.utils.scheduler import schedule
from src.api.v1.api import api_router
from src.utils.openapi import openapi
from src.utils.metrics import metrics
Expand All @@ -15,9 +16,9 @@
host, port = args.get("web.listen_address").split(":")

if not all([settings.check_prom_http_connection(prom_addr),
settings.check_reload_api_status(prom_addr),
settings.check_rules_directory(rule_path),
settings.check_fs_permissions(rule_path)]):
settings.check_reload_api_status(prom_addr),
settings.check_rules_directory(rule_path),
settings.check_fs_permissions(rule_path)]):
sys.exit()


Expand Down Expand Up @@ -56,4 +57,5 @@ def main():


if __name__ == "__main__":
schedule()
main()
8 changes: 5 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
prometheus-fastapi-instrumentator==6.1.0
python-json-logger==2.0.7
email-validator==2.0.0
fastapi==0.109.0
uvicorn==0.21.1
APScheduler==3.10.4
pytimeparse2==1.7.1
jsonschema==4.17.3
requests==2.28.2
pydantic==1.10.7
fastapi==0.109.0
uvicorn==0.21.1
PyYAML==6.0.1
jsonschema==4.17.3
httpx==0.24.0
3 changes: 2 additions & 1 deletion src/api/v1/api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from .. v1.endpoints import reverse_proxy, rules, web
from .. v1.endpoints import reverse_proxy, rules, policies, web
from fastapi import APIRouter

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

0 comments on commit 8db8d3b

Please sign in to comment.