Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Count users in keycloak_count_users metric #83

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jermarchand
Copy link

Motivation

Add a new metric which is a gauge of the total number of users on the Keycloak instance. #81

What

Add 1 Gauge :

  • keycloak_count_users

Why

Show the number of users

How

On REGISTER or CREATE/DELETE User events, count the users of the realm.

Verification Steps

Add the steps required to check this change. Following an example.

  1. Build the SPI from this branch and start Keycloak with it.
  2. Register a new user
  3. Add new user with admin-console
  4. Open the metrics endpoint in a browser.

Checklist:

  • Code has been tested locally by PR requester
  • Changes have been successfully verified by another team member

Progress

  • Finished task

Additional Notes

I'm a newby with Prometheus metrics, so fell free to comment and propose better implementation.

Until first REGISTER or CREATE/DELETE User events, the metric is not set.

@pb82
Copy link
Contributor

pb82 commented Oct 20, 2020

Thanks for the contribution @jermarchand , this looks reasonable to me

@pb82
Copy link
Contributor

pb82 commented Nov 16, 2020

@jermarchand this works as long as users are created or register through the UI. When using the API to create users (like e.g. the keycloak operator does) no register or create event is fired and the users are not counted. One solution would be to count the users on every regular and admin event. Not sure if this could lead to excessive database queries when scraping metrics often?

@jermarchand
Copy link
Author

I don't know how operator work :/
If it use the "Registration flow" a user event "Register" is generated.
If it use the Keycloak Admin REST API an admin event "CREATE USER" is generated.

@alexted
Copy link

alexted commented Nov 17, 2024

@jermarchand Is this PR still relevant?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants