aerogear / keycloak-metrics-spi

Adds a Metrics Endpoint to Keycloak
Apache License 2.0
551 stars 156 forks source link

remove route from request duration to avoid creating an excessive num… #65

Closed pb82 closed 4 years ago

pb82 commented 4 years ago

…ber of metrics

Fixes #64 and #63

This PR removes the route label from the request duration histograms. With that label a histogram was generated for every route. With a large number of users this can quickly become excessive.

Without the route label in the metric we still record the request durations of all those requests. But they are aggregated into a single Histogram.

Verification steps:

  1. a version of the spi with this change is hosted under: https://github.com/pb82/files/raw/master/keycloak-metrics-spi-1.0.5.jar
  2. deploy Keycloak with the operator and use the above url to import the metrics spi (see here: https://github.com/keycloak/keycloak-operator/blob/master/deploy/examples/keycloak/keycloak.yaml#L10)
  3. Create a few users and log in as them. Check the metrics endpoint (/auth/realms/master/metrics). There should only be one histogram exported.
pb82 commented 4 years ago

@david-martin good point about the major version bump, i'll update this.

Using a wildcard instead of the actual route might work and provide some better insights. But we would need to figure out the patterns of routes that are possible in Keycloak that can involve user (and other) IDs. Or we implement a simple solution like if (route.contains("/user")) { route = "users" }.