KeyCloak Metrics SPI
A Service Provider that adds a metrics endpoint to KeyCloak. The endpoint returns metrics data ready to be scraped by Prometheus.
Two distinct providers are defined:
- MetricsEventListener to record the internal KeyCloak events
- MetricsEndpoint to expose the data through a custom endpoint
The endpoint lives under <url>/auth/realms/<realm>/metrics
. It will return data for all realms, no matter which realm
you use in the URL (you can just default to /auth/realms/master/metrics
).
Running the tests
$ ./gradlew test
Build
The project is packages as a jar file and bundles the prometheus client libraries.
$ ./gradlew jar
builds the jar and writes it to build/libs.
Usage
Just drop the jar into the providers subdirectory of your KeyCloak installation. To enbale the event listener go to Manage -> Events -> Config. The Event Listeners configuration should have an entry named metrics-listener
.
Metrics
The endpoint will return JVM performance metrics, counters of all KeyCloak events and the number of logged in users (kc_logged_in_users).