Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
ca39e95
Add quarkus-resteasy-reactive in gradle deps
inglor Apr 30, 2024
24d6530
bump to keycloak 25.0.1 baseline
grafjo Jun 24, 2024
770bc82
drop gradle
grafjo Jun 24, 2024
0fbe3a5
drop jenkinsfile
grafjo Jun 24, 2024
d295101
remove old jboss xml file
grafjo Jun 24, 2024
e72a036
introduce mvn wrapper
grafjo Jun 24, 2024
5b04bb8
add github actions to build and publish
grafjo Jun 24, 2024
1a523ba
update readme
grafjo Jun 24, 2024
5284f2c
update readme add version compatibility with keycloak
grafjo Jun 24, 2024
0b150e0
Merge pull request #2 from focus-shift/feature/keycloak-25.0.1
grafjo Jun 24, 2024
a84f52b
remove settings.gradle
grafjo Jun 24, 2024
866ec98
release 25.0.1
grafjo Jun 24, 2024
1d099be
prepare next development iteration
grafjo Jun 24, 2024
80a5d4d
align with upstream changes rev cd08e02ecaab9bfb8b142159bf5a10f7fe7881d3
Nov 25, 2024
4214bba
Merge pull request #5 from focus-shift/upstream_changes
grafjo Nov 25, 2024
f1abf15
bump to mvn 3.9.9
Nov 25, 2024
460e11d
bump to keycloak 25.0.6
Nov 25, 2024
402127f
Merge pull request #6 from focus-shift/bump-mvn
grafjo Nov 25, 2024
78c6128
Merge pull request #7 from focus-shift/bump_keycloak_2506
grafjo Nov 25, 2024
9efbdd4
release 25.0.6
Nov 25, 2024
5733958
prepare next development iteration
Nov 25, 2024
e9b629f
bump to keycloak 26.0.1
grafjo Nov 29, 2024
a245dc6
Merge pull request #8 from focus-shift/keycloak_2601
grafjo Nov 29, 2024
5c53614
release 26.0.1
grafjo Nov 29, 2024
c1aa122
prepare next development iteration
grafjo Nov 29, 2024
1db1f7d
bump to keycloak 26.0.6
grafjo Nov 29, 2024
92c8539
Merge pull request #9 from focus-shift/keycloak_2606
grafjo Nov 29, 2024
9f86b60
release 26.0.6
grafjo Nov 29, 2024
39c980e
prepare next development iteration
grafjo Nov 29, 2024
6a85ffe
Upgrade to Keycloak 26.3.4
derTobsch Sep 17, 2025
602909c
Upgrade maven wrapper to 3.3.4 with maven 3.9.11
derTobsch Sep 17, 2025
0ec1d70
Upgrade version to 26.3.4
derTobsch Sep 17, 2025
2acb09f
Prepare for next development version
derTobsch Sep 17, 2025
0a4b071
Upgrade version to 26.3.5
derTobsch Sep 26, 2025
082c1d6
Prepare for next development version
derTobsch Sep 26, 2025
5b05c0d
adjust dependencies for keycloak 26.4.2
grafjo Oct 31, 2025
54574ad
release 26.4.2
grafjo Oct 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build

on:
push:
pull_request:

jobs:
build:
name: build
runs-on: ubuntu-latest
env:
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version"
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 21
- name: Build
run: >
./mvnw $MAVEN_CLI_OPTS
dependency:go-offline
clean verify
34 changes: 34 additions & 0 deletions .github/workflows/maven-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Release

on:
push:
tags:
- '*'

jobs:
release:
runs-on: ubuntu-latest
env:
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version"
steps:
- uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 21
- name: Build with Maven
run: >
./mvnw $MAVEN_CLI_OPTS
clean verify
- name: Extract release tag
id: vars
run: echo "version=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: keycloak-metrics-spi ${{ steps.vars.outputs.version }}
files: |
./target/keycloak-metrics-spi-*.jar
3 changes: 3 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
wrapperVersion=3.3.4
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.11/apache-maven-3.9.11-bin.zip
3 changes: 3 additions & 0 deletions .sdkmanrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Enable auto-env through the sdkman_auto_env config
# Add key=value pairs of SDKs to use below
java=21.0.5-tem
20 changes: 0 additions & 20 deletions Jenkinsfile

This file was deleted.

77 changes: 26 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,26 @@ Two distinct providers are defined:
* MetricsEventListener to record the internal Keycloak events
* MetricsEndpoint to expose the data through a custom endpoint

The endpoint is available under `<base url>/realms/<realm>/metrics` (Quarkus) or `<base url>/auth/realms/<realm>/metrics` (Wildfly).
The endpoint is available under `<base url>/realms/<realm>/metrics` (Quarkus).
It will return data for all realms, no matter which realm you use in the URL.

## Keycloak Version Compatibility

The version of this plugin is using the same version baseline like Keycloak itself.
E.g. the plugin version 25.0.1 is compatible with Keycloak 25.0.1.

## License

See [LICENSE file](./LICENSE)

## Running the tests

```sh
$ ./gradlew test
$ ./mvnw clean verify
```

## Build

There are two ways to build the project using:
* [Gradle](https://gradle.org/)
* [Maven](https://maven.apache.org/)

You can choose between the tools the most convenient for you. Read further how to use each of them.

### Gradle

The project is packaged as a jar file and bundles the prometheus client libraries.

```sh
$ ./gradlew jar
```

builds the jar and writes it to _build/libs_.

### Maven

To build the jar file using maven run the following command (will bundle the prometheus client libraries as well):

```sh
Expand All @@ -50,40 +37,9 @@ mvn package

It will build the project and write jar to the _./target_.

### Configurable versions for some packages

You can build the project using a different version of Keycloak or Prometheus, running the command:

#### For Gradle

```sh
$ ./gradlew -PkeycloakVersion="15.0.2.Final" -PprometheusVersion="0.12.0" jar
```

or by changing the `gradle.properties` file in the root of the project.

#### For Maven

```sh
mvn clean package -Dkeycloak.version=15.0.0 -Dprometheus.version=0.9.0
```

## Install and setup

### On Keycloak Widfly Distribution
> This section assumes `/opt/jboss` as the Keycloak home directory, which is used on the _jboss/keycloak_ reference container on Docker Hub.

- Drop the [jar](https://github.com/aerogear/keycloak-metrics-spi/releases/latest) into the _/opt/jboss/keycloak/standalone/deployments/_ subdirectory of your Keycloak installation.

- Touch a dodeploy file into the _/opt/jboss/keycloak/standalone/deployments/_ subdirectory of your Keycloak installation.

```bash
# If your jar file is `keycloak-metrics-spi-2.0.2.jar`
cd /opt/jboss/keycloak/standalone/deployments/
touch keycloak-metrics-spi-2.0.2.jar.dodeploy
```
- Restart the keycloak service.

### On Keycloak Quarkus Distribution

> We assume the home of keycloak is on the default `/opt/keycloak`
Expand Down Expand Up @@ -426,6 +382,25 @@ keycloak_request_duration_count{code="200",method="GET",resource="admin,admin/se
keycloak_request_duration_sum{code="200",method="GET",resource="admin,admin/serverinfo",uri="",} 19.0
```

To replace `users` or `clients` UUID values by a generic `{id}` with ```URI_METRICS_DETAILED``` enabled,
set ```URI_METRICS_UUID_HIDDEN``` to `true`

```c
# HELP keycloak_request_duration Request duration
# TYPE keycloak_request_duration histogram
keycloak_request_duration_bucket{code="200",method="GET",resource="admin,admin/realms",uri="admin/realms/master/users/{id}",le="50.0",} 6.0
keycloak_request_duration_bucket{code="200",method="GET",resource="admin,admin/realms",uri="admin/realms/master/users/{id}",le="100.0",} 6.0
keycloak_request_duration_bucket{code="200",method="GET",resource="admin,admin/realms",uri="admin/realms/master/users/{id}",le="250.0",} 6.0
keycloak_request_duration_bucket{code="200",method="GET",resource="admin,admin/realms",uri="admin/realms/master/users/{id}",le="500.0",} 6.0
keycloak_request_duration_bucket{code="200",method="GET",resource="admin,admin/realms",uri="admin/realms/master/users/{id}",le="1000.0",} 6.0
keycloak_request_duration_bucket{code="200",method="GET",resource="admin,admin/realms",uri="admin/realms/master/users/{id}",le="2000.0",} 6.0
keycloak_request_duration_bucket{code="200",method="GET",resource="admin,admin/realms",uri="admin/realms/master/users/{id}",le="10000.0",} 6.0
keycloak_request_duration_bucket{code="200",method="GET",resource="admin,admin/realms",uri="admin/realms/master/users/{id}",le="30000.0",} 6.0
keycloak_request_duration_bucket{code="200",method="GET",resource="admin,admin/realms",uri="admin/realms/master/users/{id}",le="+Inf",} 6.0
keycloak_request_duration_count{code="200",method="GET",resource="admin,admin/realms",uri="admin/realms/master/users/{id}",} 6.0
keycloak_request_duration_sum{code="200",method="GET",resource="admin,admin/realms",uri="admin/realms/master/users/{id}",} 41.0
```

## External Access

To disable metrics being externally accessible to a cluster. Set the environment variable 'DISABLE_EXTERNAL_ACCESS'. Once set enable the header 'X-Forwarded-Host' on your proxy. This is enabled by default on HA Proxy on Openshift.
Expand Down
66 changes: 0 additions & 66 deletions build.gradle

This file was deleted.

2 changes: 0 additions & 2 deletions gradle.properties

This file was deleted.

Binary file removed gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 0 additions & 5 deletions gradle/wrapper/gradle-wrapper.properties

This file was deleted.

Loading