Articles on: Developers

Keycloak /metrics endpoint

In order for Cloud-IAM to monitor any new realm metrics it must be configured accordingly

Cloud-IAM REST API /deployments/{deployment_id}/metrics endpoint yield functional metrics about your Keycloak in OpenMetrics format textual representation that came from Prometheus textual representation.

It yields counters regarding various parts of your Keycloak deployment.

Counters measure discrete events. Common examples are the number of HTTP requests received, CPU seconds spent, or bytes sent. For counters how quickly they are increasing over time is what is of interest to a user.

A response from the /deployments/{deployment_id}/metrics endpoint will yield a line (called a MetricPoint) like this one:

keycloak_login_attempts{application="keycloak",client_id="account-console",realm="master"} 2 1645446218620


For each MetricPoint:
- A MetricPoint in a Metric with the type Counter MUST have one value called Total (2 in the line example). A Total is a non-NaN and MUST be monotonically non-decreasing over time, starting from 0.
- A MetricPoint in a Metric with the type Counter SHOULD have a Timestamp (1645446218620 from the line example) value called Created. This can help ingestors discern between new metrics and long-running ones it did not see before.
- A MetricPoint in a Metric's Counter's Total MAY reset to 0. If present, the corresponding Created time MUST also be set to the timestamp of the reset.

Here is an example of Prometheus configuration to scrape metrics from Cloud-IAM deployment.

scrape_configs:
- job_name: cloud-iam
  scrape_interval: 30s
  scheme: https
  metrics_path: /deployments/{deployment-id}/metrics
  static_configs:
  - targets:
    - api.cloud-iam.com
    labels:
      host: '{my-deployment}'
  oauth2:
    client_id: '{service-account-client-id}'
    client_secret: '{service-account-client-secret}'
    token_url: 'https://iam.cloud-iam.com/auth/realms/cloud-iam/protocol/openid-connect/token'
    endpoint_params:
      grant_type: 'client_credentials'


Cloud-IAM REST API /deployments/{deployment_id}/metrics yield the following metrics:

keycloak_client_logins
counter Total successful client logins

keycloak_code_to_tokens
counter Total number of successful code to token

keycloak_login_attempts
counter Total number of login attempts

keycloak_logins
counter Total successful logins

keycloak_refresh_tokens
counter Total number of successful token refreshes

keycloak_refresh_tokens_errors
counter Total number of failed token refreshes

keycloak_request_duration_bucket
histogram Request duration

keycloak_request_duration_count
histogram Request duration

keycloak_request_duration_sum
histogram Request duration

keycloak_response_errors
counter Total number of error responses

keycloak_user_event_LOGIN
counter Generic Keycloak User event

keycloak_user_event_LOGIN_ERROR
counter Generic Keycloak User event

keycloak_user_event_REGISTER
counter Generic Keycloak User event

keycloak_user_event_REGISTER_ERROR
counter Generic KeyCloak User event

keycloak_user_event_LOGOUT
counter Generic KeyCloak User event

keycloak_user_event_LOGOUT_ERROR
counter Generic KeyCloak User event

keycloak_user_event_CODE_TO_TOKEN
counter Generic KeyCloak User event

keycloak_user_event_CODE_TO_TOKEN_ERROR
counter Generic KeyCloak User event

keycloak_user_event_CLIENT_LOGIN
counter Generic KeyCloak User event

keycloak_user_event_CLIENT_LOGIN_ERROR
counter Generic KeyCloak User event

keycloak_user_event_REFRESH_TOKEN
counter Generic KeyCloak User event

keycloak_user_event_REFRESH_TOKEN_ERROR
counter Generic KeyCloak User event

keycloak_user_event_VALIDATE_ACCESS_TOKEN
counter Generic KeyCloak User event

keycloak_user_event_VALIDATE_ACCESS_TOKEN_ERROR
counter Generic KeyCloak User event

keycloak_user_event_INTROSPECT_TOKEN
counter Generic KeyCloak User event

keycloak_user_event_INTROSPECT_TOKEN_ERROR
counter Generic KeyCloak User event

keycloak_user_event_FEDERATED_IDENTITY_LINK
counter Generic KeyCloak User event

keycloak_user_event_FEDERATED_IDENTITY_LINK_ERROR
counter Generic KeyCloak User event

keycloak_user_event_REMOVE_FEDERATED_IDENTITY
counter Generic KeyCloak User event

keycloak_user_event_REMOVE_FEDERATED_IDENTITY_ERROR
counter Generic KeyCloak User event

keycloak_user_event_UPDATE_EMAIL
counter Generic KeyCloak User event

keycloak_user_event_UPDATE_EMAIL_ERROR
counter Generic KeyCloak User event

keycloak_user_event_UPDATE_PROFILE
counter Generic KeyCloak User event

keycloak_user_event_UPDATE_PROFILE_ERROR
counter Generic KeyCloak User event

keycloak_user_event_UPDATE_PASSWORD
counter Generic KeyCloak User event

keycloak_user_event_UPDATE_PASSWORD_ERROR
counter Generic KeyCloak User event

keycloak_user_event_UPDATE_TOTP
counter Generic KeyCloak User event

keycloak_user_event_UPDATE_TOTP_ERROR
counter Generic KeyCloak User event

keycloak_user_event_VERIFY_EMAIL
counter Generic KeyCloak User event

keycloak_user_event_VERIFY_EMAIL_ERROR
counter Generic KeyCloak User event

keycloak_user_event_VERIFY_PROFILE
counter Generic KeyCloak User event

keycloak_user_event_VERIFY_PROFILE_ERROR
counter Generic KeyCloak User event

keycloak_user_event_REMOVE_TOTP
counter Generic KeyCloak User event

keycloak_user_event_REMOVE_TOTP_ERROR
counter Generic KeyCloak User event

keycloak_user_event_GRANT_CONSENT
counter Generic KeyCloak User event

keycloak_user_event_GRANT_CONSENT_ERROR
counter Generic KeyCloak User event

keycloak_user_event_UPDATE_CONSENT
counter Generic KeyCloak User event

keycloak_user_event_UPDATE_CONSENT_ERROR
counter Generic KeyCloak User event

keycloak_user_event_REVOKE_GRANT
counter Generic KeyCloak User event

keycloak_user_event_REVOKE_GRANT_ERROR
counter Generic KeyCloak User event

keycloak_user_event_SEND_VERIFY_EMAIL
counter Generic KeyCloak User event

keycloak_user_event_SEND_VERIFY_EMAIL_ERROR
counter Generic KeyCloak User event

keycloak_user_event_SEND_RESET_PASSWORD
counter Generic KeyCloak User event

keycloak_user_event_SEND_RESET_PASSWORD_ERROR
counter Generic KeyCloak User event

keycloak_user_event_SEND_IDENTITY_PROVIDER_LINK
counter Generic KeyCloak User event

keycloak_user_event_SEND_IDENTITY_PROVIDER_LINK_ERROR
counter Generic KeyCloak User event

keycloak_user_event_RESET_PASSWORD
counter Generic KeyCloak User event

keycloak_user_event_RESET_PASSWORD_ERROR
counter Generic KeyCloak User event

keycloak_user_event_RESTART_AUTHENTICATION
counter Generic KeyCloak User event

keycloak_user_event_RESTART_AUTHENTICATION_ERROR
counter Generic KeyCloak User event

keycloak_user_event_INVALID_SIGNATURE
counter Generic KeyCloak User event

keycloak_user_event_INVALID_SIGNATURE_ERROR
counter Generic KeyCloak User event

keycloak_user_event_REGISTER_NODE
counter Generic KeyCloak User event

keycloak_user_event_REGISTER_NODE_ERROR
counter Generic KeyCloak User event

keycloak_user_event_UNREGISTER_NODE
counter Generic KeyCloak User event

keycloak_user_event_UNREGISTER_NODE_ERROR
counter Generic KeyCloak User event

keycloak_user_event_USER_INFO_REQUEST
counter Generic KeyCloak User event

keycloak_user_event_USER_INFO_REQUEST_ERROR
counter Generic KeyCloak User event

keycloak_user_event_IDENTITY_PROVIDER_LINK_ACCOUNT
counter Generic KeyCloak User event

keycloak_user_event_IDENTITY_PROVIDER_LINK_ACCOUNT_ERROR
counter Generic KeyCloak User event

keycloak_user_event_IDENTITY_PROVIDER_LOGIN
counter Generic KeyCloak User event

keycloak_user_event_IDENTITY_PROVIDER_LOGIN_ERROR
counter Generic KeyCloak User event

keycloak_user_event_IDENTITY_PROVIDER_FIRST_LOGIN
counter Generic KeyCloak User event

keycloak_user_event_IDENTITY_PROVIDER_FIRST_LOGIN_ERROR
counter Generic KeyCloak User event

keycloak_user_event_IDENTITY_PROVIDER_POST_LOGIN
counter Generic KeyCloak User event

keycloak_user_event_IDENTITY_PROVIDER_POST_LOGIN_ERROR
counter Generic KeyCloak User event

keycloak_user_event_IDENTITY_PROVIDER_RESPONSE
counter Generic KeyCloak User event

keycloak_user_event_IDENTITY_PROVIDER_RESPONSE_ERROR
counter Generic KeyCloak User event

keycloak_user_event_IDENTITY_PROVIDER_RETRIEVE_TOKEN
counter Generic KeyCloak User event

keycloak_user_event_IDENTITY_PROVIDER_RETRIEVE_TOKEN_ERROR
counter Generic KeyCloak User event

keycloak_user_event_IMPERSONATE
counter Generic KeyCloak User event

keycloak_user_event_IMPERSONATE_ERROR
counter Generic KeyCloak User event

keycloak_user_event_CUSTOM_REQUIRED_ACTION
counter Generic KeyCloak User event

keycloak_user_event_CUSTOM_REQUIRED_ACTION_ERROR
counter Generic KeyCloak User event

keycloak_user_event_EXECUTE_ACTIONS
counter Generic KeyCloak User event

keycloak_user_event_EXECUTE_ACTIONS_ERROR
counter Generic KeyCloak User event

keycloak_user_event_EXECUTE_ACTION_TOKEN
counter Generic KeyCloak User event

keycloak_user_event_EXECUTE_ACTION_TOKEN_ERROR
counter Generic KeyCloak User event

keycloak_user_event_CLIENT_INFO
counter Generic KeyCloak User event

keycloak_user_event_CLIENT_INFO_ERROR
counter Generic KeyCloak User event

keycloak_user_event_CLIENT_REGISTER
counter Generic KeyCloak User event

keycloak_user_event_CLIENT_REGISTER_ERROR
counter Generic KeyCloak User event

keycloak_user_event_CLIENT_UPDATE
counter Generic KeyCloak User event

keycloak_user_event_CLIENT_UPDATE_ERROR
counter Generic KeyCloak User event

keycloak_user_event_CLIENT_DELETE
counter Generic KeyCloak User event

keycloak_user_event_CLIENT_DELETE_ERROR
counter Generic KeyCloak User event

keycloak_user_event_CLIENT_INITIATED_ACCOUNT_LINKING
counter Generic KeyCloak User event

keycloak_user_event_CLIENT_INITIATED_ACCOUNT_LINKING_ERROR
counter Generic KeyCloak User event

keycloak_user_event_TOKEN_EXCHANGE
counter Generic KeyCloak User event

keycloak_user_event_TOKEN_EXCHANGE_ERROR
counter Generic KeyCloak User event

keycloak_user_event_OAUTH2_DEVICE_AUTH
counter Generic KeyCloak User event

keycloak_user_event_OAUTH2_DEVICE_AUTH_ERROR
counter Generic KeyCloak User event

keycloak_user_event_OAUTH2_DEVICE_VERIFY_USER_CODE
counter Generic KeyCloak User event

keycloak_user_event_OAUTH2_DEVICE_VERIFY_USER_CODE_ERROR
counter Generic KeyCloak User event

keycloak_user_event_OAUTH2_DEVICE_CODE_TO_TOKEN
counter Generic KeyCloak User event

keycloak_user_event_OAUTH2_DEVICE_CODE_TO_TOKEN_ERROR
counter Generic KeyCloak User event

keycloak_user_event_AUTHREQID_TO_TOKEN
counter Generic KeyCloak User event

keycloak_user_event_AUTHREQID_TO_TOKEN_ERROR
counter Generic KeyCloak User event

keycloak_user_event_PERMISSION_TOKEN
counter Generic KeyCloak User event

keycloak_user_event_PERMISSION_TOKEN_ERROR
counter Generic KeyCloak User event

keycloak_user_event_DELETE_ACCOUNT
counter Generic KeyCloak User event

keycloak_user_event_DELETE_ACCOUNT_ERROR
counter Generic KeyCloak User event

keycloak_user_event_PUSHED_AUTHORIZATION_REQUEST
counter Generic KeyCloak User event

keycloak_user_event_PUSHED_AUTHORIZATION_REQUEST_ERROR
counter Generic KeyCloak User event

keycloak_admin_event_ACTION
counter Generic KeyCloak Admin event

keycloak_admin_event_CREATE
counter Generic KeyCloak Admin event

keycloak_admin_event_UPDATE
counter Generic KeyCloak Admin event

keycloak_admin_event_DELETE
counter Generic KeyCloak Admin event

Back to the website

Updated on: 02/01/2023

Was this article helpful?

Share your feedback

Cancel

Thank you!