Monitoring
Alauda Application Services Identity Management E1 exposes built-in metrics compatible with Prometheus. Enabling metrics allows you to monitor Keycloak's health, performance, and usage in your observability stack.
TOC
Enable MetricsKey MetricsRecommended Alerting IndicatorsConfigure Prometheus ScrapingLiveness and Readiness ProbesHealth EndpointsObservability IntegrationEvent AuditingEnable Login EventsKey Login Event TypesEnable Admin EventsView EventsEvent ListenersQuery Events via REST APIEnable Metrics
Metrics are enabled by setting the metrics-enabled option in the Keycloak CR:
Once enabled, Keycloak exposes a metrics endpoint on the management port (default: 9000), configurable via spec.httpManagement.port:
- Within the cluster:
http://<keycloak-service-name>.<namespace>:9000/metrics - From within a Pod:
http://localhost:9000/metrics
The management port is separate from the main HTTP/HTTPS port.
Key Metrics
The following categories of metrics are available:
Keycloak 26.x exposes user event metrics natively via the single metric keycloak_user_events_total with an event label (for example, event="login", event="register"). Enable it by adding --event-metrics-user-enabled=true to your build or runtime options. Third-party SPI extensions such as aerogear/keycloak-metrics-spi are not required and use a different naming convention.
Recommended Alerting Indicators
The following metrics are recommended as starting points for alerting rules:
Configure Prometheus Scraping
Add the following scrape configuration to your Prometheus instance to collect Keycloak metrics:
If you are using the Prometheus Operator, create a ServiceMonitor:
Liveness and Readiness Probes
The Keycloak Operator configures liveness and readiness probes automatically. You can customize the probe parameters in the Keycloak CR:
The probes use the management endpoint at http://<pod>:9000/health/live and http://<pod>:9000/health/ready.
Health Endpoints
Keycloak exposes health endpoints on the management port for monitoring and orchestration:
Observability Integration
For a complete observability stack, combine Keycloak's built-in capabilities with cluster-level tooling:
Keycloak 26.x supports OpenTelemetry-based distributed tracing. The Keycloak Operator provides first-class tracing configuration fields in the Keycloak CR:
Available spec.tracing fields:
Use spec.tracing for all standard tracing configuration. Only use additionalOptions for tracing-related options not covered by the first-class fields above.
Event Auditing
Keycloak provides a built-in event system that records login events and admin operations. Events can be stored in the database and forwarded to external listeners.
Enable Login Events
- In the Admin Console, go to Realm Settings > Events tab.
- In the User events settings section:
- Enable Save events.
- Set Expiration to control how long events are retained (for example,
30days). - Select the Event types to record (or leave blank to record all types).
- Click Save.
Key Login Event Types
Enable Admin Events
- In the Admin events settings section:
- Enable Save events.
- Enable Include representation to record the full request body of admin operations (useful for audit trails, but increases storage usage).
- Click Save.
Admin events record all operations performed via the Admin Console or Admin REST API, including resource type, operation type (CREATE, UPDATE, DELETE), and the admin user who performed the action.
View Events
- Login events: Go to Events > User events tab. Filter by event type, user, date range, or client.
- Admin events: Go to Events > Admin events tab. Filter by operation type, resource type, or admin user.
Event Listeners
Event listeners process events as they occur. Keycloak includes two built-in listeners:
Configure listeners in Realm Settings > Events > Event listeners.