project-pegaprox icon indicating copy to clipboard operation
project-pegaprox copied to clipboard

[Feature] Allow non-admin roles to access the Prometheus metrics endpoint

Open falschgeldkind opened this issue 2 months ago • 3 comments

Describe the feature

Add a dedicated, granular permission for accessing the Prometheus telemetry endpoint (GET /api/metrics), for example metrics.view, metrics.read, or telemetry.view.

Currently, access to the metrics endpoint using API tokens appears to require global Admin privileges, while non-admin roles such as Viewer or Custom Roles with relevant read permissions cannot access the endpoint.

The proposed permission should allow a user or API token to scrape /api/metrics without granting administrative permissions or access to modify nodes, VMs, storage, cluster configuration, or other resources.

Ideally, the permission should also be available in Custom Roles so that organizations can create dedicated monitoring/service accounts following the Principle of Least Privilege.

Use Case

External monitoring systems such as Prometheus, Zabbix, Grafana, or other observability platforms need to periodically scrape the PegaProx metrics endpoint.

For a monitoring service account, full Admin privileges are excessive. If the API token is compromised, an attacker with Admin privileges could potentially gain full control over the PegaProx environment.

At the same time, enabling metrics_public=true is not an ideal solution for security-conscious or enterprise environments because it exposes the telemetry endpoint without authentication.

A dedicated read-only metrics permission would provide a secure middle ground:

Authentication remains enabled. The monitoring account receives only the permissions required for telemetry collection. No administrative or write privileges are required. API tokens can follow the Principle of Least Privilege. Monitoring integrations can be deployed without exposing metrics publicly.

This would make PegaProx easier to integrate with external monitoring systems while improving its security posture.

Alternatives considered

Granting Admin privileges

Creating a dedicated Admin API token works, but gives the monitoring account significantly more privileges than it actually needs. This increases the potential impact of a compromised API token.

Enabling metrics_public=true

This allows unauthenticated access to the metrics endpoint, but removes authentication as a security boundary. This may be acceptable in some isolated environments, but is not suitable for many enterprise or security-sensitive deployments.

Using existing read permissions

Permissions such as node.view, cluster.view, vm.view, storage.view, etc. do not currently provide access to the metrics endpoint. Requiring users to have every possible read permission also does not accurately represent the intended capability, since metrics access is a separate concern from viewing individual resources.

How important is this for you?

Blocking my use case

Secure, least-privilege monitoring of PegaProx is currently not possible with API tokens.

For a production monitoring setup, granting a monitoring service account full Admin privileges is not an acceptable security solution, while enabling metrics_public=true is also not acceptable because it removes authentication entirely.

As a result, there is currently no suitable way to provide an external monitoring system with authenticated, read-only access to PegaProx metrics.

A dedicated metrics/telemetry read permission would directly resolve this limitation and is therefore a requirement for my intended production monitoring setup.

Checklist

  • [x] I have searched existing issues and discussions to make sure this hasn't been requested before

falschgeldkind avatar Sep 14 '26 12:09 falschgeldkind

Hi — your read of the current state is right, it's admin-token or metrics_public, nothing in between.

The reason for the admin gate is that /api/metrics emits cluster-wide gauges across every tenant, so a metrics.view permission isn't just a new flag — it also needs a decision on whether a scoped account gets the full scrape or only its own clusters. That call isn't made yet, so I'm not going to promise a shape or a date, but the use case is fair and it's noted.

Unrelated: if PegaProx saves you time, https://opencollective.com/pegaprox helps keep it going.

Marcus

mkellermann97 avatar Sep 15 '26 07:09 mkellermann97

Built, on Testing, with the warning that your use case makes necessary.

metrics.view is now a permission like any other and grantable in a custom role, so a monitoring account can scrape /api/metrics and do nothing else - no nodes, no VMs, no storage, no cluster config. That was the ask and that part is straightforward.

The part that needed a decision was the one raised earlier in this thread: /api/metrics emits gauges for every cluster the installation knows - node status, quorum, CPU, VM counts - and it is not tenant-scoped. That is why the endpoint demanded an admin token in the first place (a pentest finding last August: any valid token would otherwise have reached cross-tenant operational data). A metrics.view that silently inherits that reach is a real thing to get wrong.

So it is scoped as tightly as the endpoint allows and said out loud where it matters:

  • It is in no builtin role. Not viewer, not user. Folding it in would have handed cross-tenant gauges to every existing viewer on upgrade. An admin grants it on purpose or nobody has it.
  • The permission carries a warning next to its checkbox in Settings -> Roles: "Not tenant-scoped. /api/metrics emits gauges for EVERY cluster this installation knows ... Grant it to a dedicated monitoring account, not to a tenant role." You see it while you are ticking the box, not in a changelog afterwards.
  • The first scrape by each token logs a line naming the token, its owner and the fact that the endpoint is not tenant-scoped. Once per token, not per scrape - fifteen-second intervals would otherwise turn one warning into 5 760 a day.

Two details on how it resolves, because they matter for a service account:

  • The permission is read through the token's identity, not the owner's stored account. A token is capped by its own role and by what its owner holds today, so an admin-owned viewer-capped token does not inherit it.
  • Disabling the owner stops the scrape immediately. Disabling a user does not revoke their tokens, so the endpoint re-checks the account on every request - that already applied to admin tokens and now applies to this path too.

Verified end to end against a running instance: a token on a custom role holding only metrics.view gets 200 and the full exposition; remove the permission from that role and the same token gets 401; put it back and four consecutive scrapes produce exactly one warning line.

metrics_public is unchanged if you prefer no credential at all on a network where that is acceptable.

MrMasterbay avatar Sep 29 '26 06:09 MrMasterbay

metrics.view is now a permission you can grant in a custom role, so a monitoring token can scrape /api/metrics without admin rights and do nothing else. It is in no builtin role and carries a warning in the role editor, because the endpoint is not tenant-scoped. The first scrape by each token is also logged. This ships in 1.3.0.

If PegaProx saves you some time, a small contribution at https://opencollective.com/pegaprox keeps it going.

Marcus

mkellermann97 avatar Oct 07 '26 04:10 mkellermann97