Keycloak service level indicators and SLOs

How to define availability, latency and error SLOs for a self-hosted Keycloak using its Prometheus metrics, the http-metrics-slos setting, recording rules, dashboards and error budget burn alerts.

On this page

Keycloak service level indicators and SLOs: what teams must decide first

Keycloak service level objectives (SLOs) are written targets for how often Keycloak must answer correctly and how quickly, measured from its own metrics. A team needs them when Keycloak is a login dependency for several applications and nobody has agreed what "up" means. A process can be running and still fail every login because the database is slow or an upstream identity provider is timing out, so an uptime check alone does not settle the question. Agree the definition of a successful request before anyone sets a target.

Keycloak exposes Prometheus-format metrics at /metrics on its management interface when it is started with --metrics-enabled=true. HTTP request histograms are optional and must be enabled separately, so confirm which ones your release provides in the observability guide, Gaining insights with metrics. These series are the raw material for service level indicators (SLIs): the measured ratio of good events to total events, such as successful token requests divided by all token requests. An SLO is the target you set for that ratio over a window, and the error budget is the share of failures that target allows before you must act. Decide which endpoints count as user-facing logins, which status codes count as errors, and whether a slow response is a failure, because those choices determine what the SLI measures.

DeployOpen plans and implements this work inside your own infrastructure, including the scrape configuration, recording rules, dashboards and burn-rate alerts. Before that work starts, the operations lead, the application owners and the security team should agree on the questions that set the targets: which realms and clients are critical, what share of failed logins is acceptable for each, and who responds when the error budget burns faster than planned. Ask for those decisions to be written into the scope so the metrics, rules and alerts can be tested against them.

Which service level indicators fit which Keycloak role

Most traffic in a typical Keycloak deployment comes from browser redirects and token requests made by applications using OpenID Connect. For this role, availability means the sign-in path works end to end: the authorization endpoint, the login pages, the token endpoint and the discovery document that clients fetch. Latency is felt directly by users during the redirect chain, so measure the login flow itself rather than an average across every request. Success and latency measures for these paths come from the HTTP request metrics that the http-metrics-slos setting enables, described in the Keycloak metrics guide.

  • Availability: the success ratio of requests to the authorization and token endpoints, excluding expected client errors such as wrong passwords.
  • Latency: request duration for the token endpoint and login pages, at a percentile agreed with application owners.
  • Error: the share of 5xx responses on sign-in paths, which signals that Keycloak or its database is failing users.
  • Discovery and key endpoints: availability of the well-known configuration and signing key endpoints, since applications cache these and an outage can spread slowly.
  • Realm split: track the busiest realms separately so one high-volume realm does not hide a failing smaller one.

Check that the success measure excludes expected 4xx responses and that each indicator names the endpoints it covers.

Example SLO targets and how to choose your own

Pick targets from business impact and your own incident history, not from a number that looks good on a slide. Start by naming the three user paths that matter most for Keycloak: browser logins through the authorization endpoint, token issuance at the token endpoint that your applications call on every session refresh or API access, and admin console use by your operations staff. Each path has different tolerance. A login outage stops every application behind Keycloak, while a slow admin console mostly delays administrators. Set availability, latency and error targets per path, and for each one ask your stakeholders what an hour of failure costs, how many incidents in the last year would have breached a proposed target, and which of those incidents were caused by Keycloak rather than its database, LDAP source or reverse proxy.

An illustrative starting point could be a monthly availability target for logins and token issuance that your team can actually defend, a latency target expressed as a percentile for successful token requests, and an error ratio for 5xx responses on the same endpoints. Treat the resulting error budget as a planning tool. The Prometheus overview says the system values reliability over precision, and that it is not the right choice where 100% accuracy is required. Scrape intervals, counter resets during restarts and histogram bucket boundaries all make the computed percentage approximate, so review a target against the raw request counts before you promise it externally. Confirm with your stakeholders who signs off on each target, how often they are revisited after upgrades, and whether the admin console target is set separately from login targets at all.

Once targets are agreed, record them in the same document as the alert thresholds and the owner of each decision, so changes go through a review instead of a dashboard edit. The Keycloak metrics you enable with --metrics-enabled=true and the http-metrics-slos setting give you the raw series, but the targets themselves are a business decision. Revisit them after any major release change, a database migration or a significant federation change, because those events alter both the baseline latency and the failure modes your budget has to absorb.

How to set up Keycloak SLO monitoring

This sequence takes a running Keycloak from raw metrics to alerts that fire when the error budget burns too fast, so the team can see availability and latency against agreed targets. Each step ends with a check that confirms the previous layer works before the next one is built.

  1. Enable the metrics endpoint on the management interface

    The Keycloak administrator starts Keycloak with --metrics-enabled=true and confirms that Prometheus-format metrics are served at /metrics on the management interface, not on the public frontend. Restrict that port with network rules so only the monitoring network can reach it. Check the key names and the management port setting against the observability guide for your exact Keycloak version before you change the startup configuration. The step is done when a request to /metrics from the monitoring host returns series, and a request from a public address does not.

  2. Turn on HTTP metrics and SLO histograms

    Enable the http-metrics-slos setting and the HTTP request histograms described in the observability guide, then restart Keycloak in a non-production environment first. The platform owner decides which latency buckets matter for the login and token endpoints, because the buckets set the precision of later latency SLIs. Confirm the exact setting name for your version in the observability guide. The step is done when the metrics output includes HTTP request duration series labeled by path or status code, and the series appear after a test login.

  3. Scrape Keycloak targets from Prometheus

    The monitoring engineer adds a scrape job to Prometheus that points at each Keycloak node's management address and metrics path, using static configuration or service discovery that matches the platform. List every node in a cluster so that a single failed node does not hide the rest of the fleet. Prometheus pulls metrics over HTTP, so confirm the network path and any authentication the metrics endpoint requires. The step is done when every Keycloak instance shows as up on the Prometheus targets page.

  4. Validate series with PromQL

    Before writing any rule, the engineer runs PromQL queries against the live data to confirm that request counts, error codes and duration histograms behave as expected during a controlled login test. Check that each series carries the labels needed to separate successful responses from server errors, and that counters increase after test traffic. Prometheus values reliability over precision, so compare query results with a known test count to see how close they are. The step is done when the team can state the request rate, error ratio and latency quantile for the login path from queries alone.

  5. Write recording rules for the SLIs

    The monitoring engineer writes Prometheus recording rules that compute the availability SLI (non-error requests as a share of all requests), the latency SLI (requests under the chosen threshold as a share of all requests) and the error ratio over short and long windows. Keep the rule names and label filters in version control so reviewers can see every change to the SLI definitions. The step is done when the recording rules load without errors and the computed series return sensible values that match the PromQL checks from the previous step.

  6. Build dashboards for the SLOs

    The team builds Grafana dashboards that plot each SLI against its SLO target, show the remaining error budget for the period and break down errors by endpoint so that login, token and admin traffic can be read separately. Store the dashboards as provisioned files where the platform allows, so they are reviewed and restored like other configuration. The step is done when a responder can open the dashboard during a test failure and see the budget dropping on the correct endpoint.

  7. Add burn-rate alerts and route them

    The engineer adds Prometheus alerting rules that fire when the error budget is being consumed too quickly over a short window and a longer confirming window, then routes them through Alertmanager, which should be configured to receive from every Alertmanager instance so that grouping, silences and inhibition work as intended. Test each alert with a deliberate fault in a non-production realm and confirm that it reaches the on-call channel once and resolves when the fault clears. The step is done when a simulated burn produces a single grouped notification, and the alert resolves automatically after recovery.

How Keycloak metrics become SLO alerts

The diagram starts at Keycloak, which serves Prometheus metrics at /metrics on its management interface when metrics are enabled. Prometheus scrapes that endpoint from inside the trust boundary, evaluates recording rules that compute the availability, latency and error SLIs, and feeds Grafana dashboards that read those rules. When burn-rate alert conditions fire, Prometheus sends alerts to an Alertmanager cluster, and every Alertmanager instance must be listed in the Prometheus configuration rather than behind a load balancer. Check that the management interface is reachable only by the scraper and that each Alertmanager instance receives alerts.

Keycloak metrics flow through Prometheus recording rules to dashboards and Alertmanager.

Recording rules and dashboards that keep SLO queries fast

Recording rules pre-compute the expensive parts of each SLO so that dashboards and alerts read a small set of series instead of rescanning raw Keycloak request histograms on every refresh. For each indicator, create one rule for the request success ratio and one for each latency quantile you track, using the metrics exposed at /metrics once --metrics-enabled=true is set and the HTTP histograms are on. Name the rules with one convention across the team, such as the level:metric:operations pattern Prometheus recommends, so that the availability, latency and error budget series for a given realm or instance are predictable to anyone reading them later. Keep the labels that split traffic (for example, the route or status class) only where an SLO actually needs them, because every extra label multiplies the series a rule produces.

Dashboards should show three things per indicator: the current SLI over the SLO window, the remaining error budget, and the burn rate over a short and a long window. Burn rate is the signal that drives alerting on budget consumption, so the dashboard should display it next to the alert thresholds that use it, which keeps the on-call engineer and the service owner looking at the same numbers. Confirm which Grafana version your team will standardize on before building these panels, since the current Grafana releases and their support windows should be checked against your upgrade policy. Note also that Prometheus local storage defaults to 15 days of retention and is not clustered or replicated. A monthly or quarterly SLO report therefore needs remote write to external long-term storage, and the team must confirm how long SLO history must be kept, who owns that store and how it is backed up before the first report is promised.

Security and operational risks in SLO monitoring

SLO monitoring for Keycloak creates its own attack surface and operating burden. The metrics expose internal detail, the time series store grows with every label you add, and the alerting chain can fail silently or wake people for the wrong reasons. The cards below name the controls that keep the monitoring useful and contained.

Management endpoint exposed publicly

Keycloak serves /metrics on its management interface only when started with --metrics-enabled=true. That interface should never share a hostname or reverse proxy route with public frontend URLs. Confirm that your proxy blocks the management port and path from the internet, and that Prometheus reaches it only over a private network. Exposed metrics reveal request volumes, cache behavior and runtime details an attacker can use for planning.

Keycloak metrics docs

Label cardinality inflating storage

Each unique combination of label values creates a separate time series. Per-realm, per-client or per-path labels on HTTP histograms multiply quickly in a large deployment, and Prometheus stores every series it scrapes. Before enabling the optional HTTP histograms, list every label they add, check how many values each can take, and drop labels that do not feed an SLO or an alert. Review cardinality after each Keycloak upgrade, since new metrics can appear in a minor release.

Alerts that page on noise

A burn-rate alert set too tight fires on short login spikes that consume little of the error budget, and teams learn to ignore it. Pair a fast-burn window with a slow-burn window so that only sustained error budget consumption pages someone, and send everything else to a ticket queue. Review every page over a fixed period and remove alerts that nobody acted on. Tune thresholds against real traffic from your own realm, not against defaults copied from a tutorial.

Prometheus as a single node

Prometheus local storage is not clustered or replicated, so a failed server means a gap in SLO history and a silent loss of alerting until someone notices. Treat the server like any other single-node database: plan disk capacity for the default retention of 15 days or a size limit you set, back up configuration, and monitor the monitor. If you need longer history or redundancy, decide early on remote write to external long-term storage, and confirm how error budget reports behave during a gap.

Prometheus storage docs

Alertmanager cluster configuration

Alertmanager groups, inhibits and silences alerts, and it can run as a cluster for high availability through its --cluster flags. Prometheus should send alerts to every Alertmanager instance rather than through a load balancer, so that a node failure does not drop notifications. Check that each instance receives the same configuration, that silences replicate across the cluster, and that a test alert reaches the on-call channel from each Prometheus server.

Alertmanager docs

Dashboards revealing user and realm detail

SLO dashboards built on Grafana can expose realm names, client identifiers and error messages that reveal which applications users sign in to. Restrict dashboard access by role, require authentication for the metrics endpoint in Grafana, and keep secure and SameSite cookies enabled. Review which data sources and panels each viewer role can open, and confirm that shared dashboard links and snapshots are disabled for anyone outside the operations team.

Grafana hardening docs

Questions teams ask before setting Keycloak SLOs

What drives the cost of setting Keycloak SLOs?

The main cost drivers are how much instrumentation work the Keycloak deployment needs, how much Prometheus and Grafana infrastructure already exists, how many recording rules and dashboards the team wants, and how much ongoing tuning follows. Instrumentation means enabling metrics with --metrics-enabled=true, deciding whether the optional HTTP request histograms are needed for latency SLOs, and making sure the scrape path reaches the management interface. Infrastructure cost comes from storage, retention and any remote long-term storage. Rule and dashboard work is largely one-time, while tuning recurs as traffic patterns and releases change. Ask any quote to separate these components so you can see what is one-time and what recurs.

Can our own team define Keycloak SLOs without a partner?

Yes, a team with Keycloak administration, Prometheus and PromQL experience and someone who can speak for the business about acceptable login failure can do this internally. The work needs skills in Keycloak metrics, Prometheus recording and alerting rules, Grafana dashboards, and the operational habits of error budget reviews. The harder part is usually agreeing on what counts as a good login and which user journeys matter, which requires product and security stakeholders as well as engineers. Teams without spare capacity often engage a partner for the initial design and leave ongoing tuning with their own staff.

How long does SLO work take for a Keycloak deployment?

Duration depends on scope: how many realms and clients are in scope, how many SLOs the team wants, whether Prometheus and Grafana already run, and how much incident history is available to calibrate targets. A single cluster with existing monitoring is a much smaller piece of work than a multi-site deployment with new observability stacks. No fixed figure applies across environments, so ask for a timeline in the written scope, and ask what is assumed about existing tooling and access. Most engagements are fixed-scope, so scope, deliverables and timelines are agreed in writing before work starts.

What does DeployOpen need from our team to start?

The work needs several inputs before design starts:

  • Read access to the running Keycloak environment, including the management interface where metrics are exposed, and a test or staging instance where rules can be checked.
  • Access to the existing Prometheus, Alertmanager and Grafana instances, or a decision on where they will run.
  • Named stakeholders from application owners, the identity team, security and the service desk who can agree on critical login journeys and acceptable failure levels.
  • Incident history, support tickets and any existing availability reports, so targets reflect real behavior.
  • Details of the hosting environment, load balancer and reverse proxy, since these affect which errors Keycloak itself records.

Confirm each item in the written scope, because gaps here usually extend the timeline.

How do SLOs reduce alerting noise for Keycloak?

SLOs reduce noise when alerts fire on the rate at which error budget is being consumed rather than on every raw error spike. A burn-rate alert uses two windows, a short one to catch fast failures and a longer one to confirm the problem persists, so brief blips from a database failover or a single bad client do not page the on-call team. Teams that alert on raw error counts often find that routine failures from misconfigured applications drown out real incidents. Expect some tuning after go-live, because thresholds set before real traffic patterns are known can be too sensitive or too lax.

Do SLOs replace load testing or performance troubleshooting?

No. SLOs tell you that login availability or latency has moved outside its target, but they do not explain why or show how the system behaves at a load you have not yet seen. Load testing answers capacity questions before a release or a traffic event, and performance troubleshooting uses thread dumps, Java Flight Recorder recordings, database pool and cache signals, and traces to find the cause. The SLO work and these activities complement each other: the SLO dashboard flags the problem, and the other practices explain it. Plan load testing and troubleshooting runbooks as separate pieces of work.

Which Prometheus and Keycloak versions should we confirm before we start?

Confirm the Keycloak version in use against the current release, which is 26.8.1, and check the upgrade notes for any changes to metrics or logs you depend on. For Prometheus, check whether your deployment is on the current long-term support line, which is 3.13, or a newer minor release, since minor releases stop receiving bug fixes after six weeks. Confirm the Grafana version and whether its database is MySQL or PostgreSQL, because SQLite is not suited to production or high availability. Each version choice affects which recording rules and dashboard panels will work without changes, so ask for the version matrix in the written scope.

Official documentation for Keycloak metrics and Prometheus alerting

Start with the Keycloak observability guide, Gaining insights with metrics, before you define any SLO. It explains how to start Keycloak with --metrics-enabled=true, which Prometheus-format metrics appear at /metrics on the management interface, and which optional HTTP request and cache histograms you can switch on. Those histograms are the raw material for availability, latency and error indicators, so confirm in the guide which metric names and labels your Keycloak version exposes before you write any recording rule. Check the guide against the release you actually run, since the current release is 26.8.1 and metric details can change between versions. You can read it at Keycloak: Gaining insights with metrics.

The Prometheus overview explains the pull model, service discovery, static scrape configuration and PromQL, which you need to write the ratio and burn-rate expressions that turn histograms into SLO signals. Read the Prometheus overview for the concepts, then the Prometheus storage page to plan retention, since local storage is single-node and not replicated, and the default 15-day retention may not cover the windows your SLO reporting needs. The release cycle page tells you which Prometheus line receives bug fixes and for how long, which matters when you choose a version to pin for production monitoring.

The Alertmanager documentation covers how alerts from Prometheus are grouped, inhibited and silenced, and how Alertmanager runs as a cluster using its --cluster flags. This is where error budget burn alerts are routed to people, so decide early who is paged for a fast burn and who receives a slow burn ticket. Prometheus should be configured to reach every Alertmanager instance rather than a load balancer in front of them. Confirm the alerting path in a test environment before relying on it for a Keycloak SLO, because an alert that never reaches a responder is not an alert. Start with the Alertmanager documentation.

How DeployOpen scopes and delivers Keycloak SLO work

DeployOpen plans, implements and documents Keycloak service level indicators and SLOs inside your own infrastructure, from the Prometheus metrics your Keycloak exposes through the alerts your on-call team receives. Each engagement starts with a written scope so you know which indicators, targets, dashboards and alert routes are included before work begins.

How we scope

  • Review which Keycloak endpoints, realms and login flows users depend on before proposing any availability or latency indicator.
  • Confirm where Prometheus and Alertmanager run, who owns them, and how long metrics must be retained.
  • Agree in writing which SLO targets, recording rules, dashboards and alert routes are in the fixed scope.

How we build

  • Enable metrics on the management interface and confirm the /metrics endpoint is reachable only from your monitoring network.
  • Configure the HTTP metrics SLO settings and recording rules, then test them against real traffic from a staging realm.
  • Build dashboards and multi-window error budget burn alerts, and test each alert with a controlled failure before handover.

How we hand over

  • Document each indicator, its query, the target and the reasoning behind it so your team can change targets later.
  • Walk through the dashboards and burn alert runbooks with the engineers and on-call staff who will respond to them.
  • Deliver configuration as files in your own repositories, so the SLO definitions can be reviewed and versioned like other code.

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers after the initial handover.
  • Revisit SLO targets and alert thresholds when Keycloak, Prometheus or Alertmanager versions change in your environment.
  • Ask for a quote based on the written scope, covering which parts are one-time work and which recur under a retainer.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.