Keycloak Database Metrics
This documentation covers the information about Keycloak’s connection to the database Keycloak.
Enable Keycloak metrics
Keycloak exposes metrics on the management interface endpoint /metrics
.
To enable, use the build time option --metrics-enabled=true
.
On a Kubernetes cluster, using the Keycloak Operator, metrics can be enabled by in the Keycloak CR addionalOptions
as shown below:
apiVersion: k8s.keycloak.org/v2alpha1
kind: Keycloak
metadata:
labels:
app: keycloak
name: keycloak
spec:
additionalOptions:
- name: metrics-enabled
value: 'true'
Additional information can be found here.
Database connection pool
Configure Keycloak to use a fixed size database connection pool. See Concepts for database connection pools for more information.
If there is a high count of threads waiting for a database connection, increasing the database connection pool size is not always the best option. It might overload the database which would then become the bottleneck. Consider the following options instead:
|
Metric | Description |
---|---|
|
Idle database connections. |
|
Database connections used in ongoing transactions. |
|
Threads waiting for a database connection to become available. |
Additional information on the Keycloak metrics
endpoint can be found here.