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

Add counter metrics for client_login, refresh_token and code_to_token #85

Merged
merged 2 commits into from
Nov 16, 2020

Conversation

tlereste
Copy link
Contributor

Motivation

To improve Keycloak observability @ Cdiscount (e-commerce platform), we need to add new gauge metrics with client_id and error informations.

This PR will also close the issue #59

What

Adding new gauge metrics :

  • keycloak_client_logins
  • keycloak_failed_client_login_attempts
  • keycloak_refresh_tokens
  • keycloak_refresh_tokens_errors
  • keycloak_code_to_tokens
  • keycloak_code_to_tokens_errors

Why

We need to have the client_id and error informations for theses metrics.

How

I added theses metrics based on the events :

  • CLIENT_LOGIN
  • CLIENT_LOGIN_ERROR
  • REFRESH_TOKEN
  • REFRESH_TOKEN_ERROR
  • CODE_TO_TOKEN
  • CODE_TO_TOKEN_ERROR

Verification Steps

  1. Build the SPI from this branch and start Keycloak with it.
  2. Login with client (grant_type = "client_credential")
  3. Refresh a token (grant_type = "refresh_token")
  4. Do a authorization (grant_type = "authorization_code")
  5. 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

NA

@tlereste tlereste changed the title Add new metrics Add counter metrics for client_login, refresh_token and code_to_token Oct 23, 2020
@clementcur
Copy link

clementcur commented Nov 13, 2020

Hi @pb82, any chance you can take a look?

@pb82
Copy link
Contributor

pb82 commented Nov 13, 2020

Hey @clementcur , yep sorry. I was planning to make some time for the pull requests in this repo. I'll see if I can get through them today.

@@ -125,6 +125,44 @@ keycloak_failed_login_attempts{realm="test",provider="keycloak",error="invalid_u
keycloak_failed_login_attempts{realm="test",provider="keycloak",error="user_not_found",client_id="application1"} 2.0
```

##### keycloak_client_logins
This counter counts every client login.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly is a client_login and how does it differ from a normal login event (which already has a client label)?

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.

None yet

3 participants