What Keycloak events are
Keycloak can record what happens in a realm as events. There are two kinds. Login events, also called user events, record what users and apps do: sign-ins, token requests, profile changes, emails sent. Admin events record changes administrators make to the realm, in the admin console or through the admin API.
Events answer the questions that come up in production. Who signed in, from where, and when? Why did a sign-in fail? Who changed this client’s redirect URIs last week? Without events, those answers are gone.
Every event has a type. Knowing the types is what turns a long list of records into something you can search, alert on and explain to an auditor.
How Keycloak 26 records events
Saving is off by default for both kinds. You turn it on per realm under Realm settings, Events. Once on, events are stored in the Keycloak database and appear under Events in the admin console. They can also be read through the admin API.
Login events
A login event has a type, a time, the realm, the client, the user, the IP address and a set of details. When a step fails, Keycloak records the same type with _ERROR at the end and an error code. A wrong password, for example, is a LOGIN_ERROR with the error invalid_user_credentials.
You can choose which types are saved. Saving fewer types keeps the tables smaller; saving the error types is usually the part worth keeping.
Admin events
An admin event has an operation type, a resource type, the resource path and who made the change. The operation is one of CREATE, UPDATE, DELETE or ACTION. The resource type says what was changed, such as USER, CLIENT or REALM_ROLE_MAPPING.
With Include representation turned on, each admin event also keeps the JSON of the change. That makes events far more useful for audits, but the JSON can contain personal data.
Expiration
Saved events stay in the database until their expiration. Set an expiration for each kind, or the event tables keep growing for as long as the realm exists.
Reading events through the admin API
Both kinds can be queried with filters, which is how most teams feed them into their own tools.
GET /admin/realms/acme/events?type=LOGIN_ERROR&max=50
GET /admin/realms/acme/admin-events?operationTypes=DELETE&resourceTypes=USERThe caller needs the view-events role of the realm-management client. The Admin API request builder shows how to get a token for these calls.
What this tool does
The reference lists the common built-in login event types with what each means, grouped by area: sign-in, tokens, device flow, account, email, identity providers, clients and admin. Each entry shows its _ERROR twin.
For admin events it lists the four operation types and the resource types, each with a short meaning. A search box finds a type by its id or by a word such as token or email. Searching for an _ERROR type finds its base type.
What it does not do
It does not read your realm’s events or connect to your server. It lists common built-in types, not every one; your version may record a few more, and extensions can add their own. The list of event types on your realm’s Events settings is the complete one for your server.
How to use it
- Choose Login events or Admin events.
- Search by type, for example
CODE_TO_TOKEN, or by a word such as refresh. - Read what the type means and which area it belongs to.
- Use the type in an event filter, an admin API query or an alert rule.
Event types worth knowing first
| Type | Why it matters |
|---|---|
LOGIN and LOGIN_ERROR | Every sign-in and every failed one. The base of most dashboards and alerts. |
CODE_TO_TOKEN_ERROR | An app failed to exchange its code. Often a redirect URI, PKCE or client secret problem. |
REFRESH_TOKEN_ERROR | Refresh failed, often because the session ended. Spikes can follow a timeout change. |
CLIENT_LOGIN | A service account got a token. Useful to see which jobs call your APIs. |
UPDATE_PASSWORD | A user changed their password. Worth watching after an incident. |
SEND_RESET_PASSWORD | A reset email was sent. Many in a short time can mean someone is probing accounts. |
IDENTITY_PROVIDER_LOGIN | A sign-in through Google, a SAML provider or another identity provider. |
IMPERSONATE | An admin acted as a user. Every one should be explainable. |
Where it pays off
Events help most when something goes wrong, and when someone asks what happened.
Debugging sign-in problems
When a user says they cannot sign in, filter login events by their username. The error code on the failed event usually says why: wrong password, disabled account, expired code or invalid redirect URI.
Audits
Admin events with representations show who changed what and when. For an audit, that is the record of every change to clients, roles and users made through the console or the API.
After an upgrade or migration
Watch LOGIN_ERROR, CODE_TO_TOKEN_ERROR and REFRESH_TOKEN_ERROR for the first hours after moving a realm or upgrading Keycloak. A rise points at a client, a redirect URI or a secret that did not come across.
Detecting attacks
Many LOGIN_ERROR events for different users from one address suggest password spraying. Many for one user suggest guessing, which brute force detection is there to slow down.
Common problems and fixes
| Problem | Cause | Fix |
|---|---|---|
| The Events page is empty | Saving is off. | Turn on saving under Realm settings, Events. |
| Only some types appear | Saving is limited to selected types. | Add the types you need to the saved list. |
| Admin events have no details | Include representation is off. | Turn it on for admin events. |
| The database keeps growing | No expiration is set. | Set an expiration for login and admin events. |
| 403 when reading events through the API | The token lacks the role. | Assign view-events of the realm-management client. |
Security and privacy notes
- Login events hold IP addresses and usernames. Treat them as personal data, with a retention period you can explain.
- Admin event representations can include user details. Turn them on only if you need them, and limit who can read events.
- Events stored in the database are only as safe as the database and its backups.
- Event listeners can send events elsewhere, such as to a log pipeline. Keep their output protected like the events themselves.
Best practices
- Turn on saving for both kinds before you go live, not after the first incident.
- Save error types even if you skip some success types.
- Set an expiration that matches your retention policy.
- Alert on unusual rates of
LOGIN_ERROR,SEND_RESET_PASSWORDandIMPERSONATE. - Review admin events after every change window.