The Simplest Way to Make OIDC and Prometheus Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams pair oidc and prometheus to tie metric queries to real user accounts. The OpenID provider checks who the user is before they view time-series data. Prometheus collects and stores metrics well, but it lacks built-in user login checks. OpenID Connect adds identity tokens so teams can control who reads or writes metrics. This setup lets developers run live queries during incidents using their own work accounts. How oidc and prometheus share user data First, an engineer logs in through the

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

Teams pair oidc and prometheus to tie metric queries to real user accounts. The OpenID provider checks who the user is before they view time-series data.

Prometheus collects and stores metrics well, but it lacks built-in user login checks. OpenID Connect adds identity tokens so teams can control who reads or writes metrics. This setup lets developers run live queries during incidents using their own work accounts.

How oidc and prometheus share user data

First, an engineer logs in through the company identity provider. The identity provider checks their password and multi-factor code. Then, the provider issues a signed JSON Web Token with the user email and group claims. The web app or client tool sends this token along with the metric query.

Next, the web server in front of the metric store checks the token signature. It fetches the public keys from the identity provider to prove the token is real. It also checks that the token has not expired and matches the right audience.

After the check passes, the web server reads the group claims inside the token. It matches those groups to metric permissions, such as read-only view or admin actions. The server then forwards the approved PromQL query to the metric engine and returns the results.

Common failure modes and how to scope roles

Many teams start by sharing one static password for all metric queries. When an engineer leaves the company, the team must rotate that shared password everywhere. Worse, if someone runs a heavy query that crashes the server, nobody knows who ran it.

Another common mistake is using long-lived bearer tokens for metric scraping and querying. If a broad token leaks in a code repo, attackers can read sensitive system metrics. Metrics often contain private labels like internal hostnames, customer emails, or phone numbers.

End-to-End Encryption + K8s OIDC Authentication: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

To fix this, teams must scope roles tightly inside their identity provider. Create separate groups for metric readers, alert editors, and system admins. Give most engineers read-only permissions so they cannot delete time-series data or reload settings.

You should also restrict network paths so users enforces policy on the login check. Bind the metric server to a local interface or a private subnet. Only allow network traffic from the web server that checks the OpenID tokens.

Keeping metric labels and audit logs clean

Even with good login rules, sensitive data can still slip into metric labels. Developers sometimes attach user emails, phone numbers, or card numbers to custom app metrics. When engineers run broad queries, those raw values show up on dashboards and in alerts.

Teams should set up rules that strip or mask sensitive labels before storage or display. Data masking rewrites matched fields in results so sensitive values stay protected during fixing. You should also log every query alongside the user identity from the OpenID token. Clear audit logs show who queried which metrics and when they ran the request.

Govern statements and responses across databases and APIs

Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.

First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

Does Prometheus support OpenID Connect out of the box?

No, the core metric server does not include built-in user login or OpenID support. You must place an logging in web server or tool in front of the metric API.

How do automated scraper jobs handle OpenID tokens?

Automated scrapers use the client credentials flow to get short-lived tokens from the identity provider. The scraper sends this token in the request header every time it pulls metrics.

Can I limit which metrics a specific team can query?

Yes, you can map identity provider group claims to specific tenant headers or label filters. This ensures each team only queries metrics that match their own service labels.

The query runs. The emails stay hidden.