Skip to content

Commit

Permalink
feat(api): no auth for processing metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
talboren committed Dec 30, 2024
1 parent 7a34226 commit 3b1b63b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
39 changes: 26 additions & 13 deletions keep/api/routes/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,32 @@
router = APIRouter()

CONTENT_TYPE_LATEST = "text/plain; version=0.0.4; charset=utf-8"


@router.get("/processing", include_in_schema=False)
async def get_processing_metrics(
request: Request,
authenticated_entity: AuthenticatedEntity = Depends(
IdentityManagerFactory.get_auth_verifier(["read:metrics"])
),
):
registry = CollectorRegistry()
multiprocess.MultiProcessCollector(registry)
metrics = generate_latest(registry)
return Response(content=metrics, media_type=CONTENT_TYPE_LATEST)
NO_AUTH_METRICS = config("KEEP_NO_AUTH_METRICS", default=False, cast=bool)

if NO_AUTH_METRICS:

@router.get("/processing", include_in_schema=False)
async def get_processing_metrics(
request: Request,
):
registry = CollectorRegistry()
multiprocess.MultiProcessCollector(registry)
metrics = generate_latest(registry)
return Response(content=metrics, media_type=CONTENT_TYPE_LATEST)

else:

@router.get("/processing", include_in_schema=False)
async def get_processing_metrics(
request: Request,
authenticated_entity: AuthenticatedEntity = Depends(
IdentityManagerFactory.get_auth_verifier(["read:metrics"])
),
):
registry = CollectorRegistry()
multiprocess.MultiProcessCollector(registry)
metrics = generate_latest(registry)
return Response(content=metrics, media_type=CONTENT_TYPE_LATEST)


@router.get("")
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "keep"
version = "0.33.2"
version = "0.33.3"
description = "Alerting. for developers, by developers."
authors = ["Keep Alerting LTD"]
packages = [{include = "keep"}]
Expand Down

0 comments on commit 3b1b63b

Please sign in to comment.