Admin and Login Events in Keycloak

Chandra Sharma
4 min readJun 11, 2021

--

Keycloak Login and Admin Events Image

Do you want to know when the specific event happened during Keycloak’s different interaction?

Good news is that Keycloak comes with Events Logging for the realms. So, whether the User is created, Login is failed or any new Client is created, you will get to know all of this.

Where are Events located in Keycloak?

After successfully logging into your selected realm (by default Master Realm), you will be able to locate the Events in the Left Hand Side Menu bar as below:

Events in the Menu Bar
Events in the Menu Bar

Enabling Admin Events

After navigating to the Events Menu, you can see three tabs.

  • Login Events — In this tab, all the events related to login are displayed. Event can be — login, logout, password reset etc. These events are viewable from both Admin Console as well as Account Management Console.
  • Admin Events — This tab lists down all the admin related events and are persisted to make them available in the Admin Console.
  • Config — This is the tab where all the confgiration happens which includes persisting Login Events and Admin Events.

Config Tab

By default “Save Events” is set to OFF. This is done in order to let this job to be done by the admin so that they can select the required events. We will see that there are N number of events which can be captured.

Config Tab
Config Tab

Login Events Settings

After enabling “Save Events”, you will see lots of event categories from which you can select.

Screen displaying the events
Screen displaying the events that can be selected

Can I customize the Events recording duration?

Yes, Keycloak provides you the option to configure the Expiration of the events. You can set the expiration as the units like Minute, Hours and Days.

Setting expiration for events
Setting expiration for events

How to check if my settings are working?

After doing the above steps, click on “Save” to persist our settings in Keycloak. Next, logout of the Admin Console and then try login again. Go to Events Menu on the Left Hand Side and you will be landed on Login Events.

Now, here you will be able to see all the events that have happened so far.

Login Events as captured by Keycloak with details

Admin Events

For Admin Events settings, we can again go to Config Tab. Here you will see the option to enable the Admin Events.

Admin Events Settings
Admin Events Settings

How to check Admin Events working?

Admin events are triggered for the cases when realms is updated, user is created and for other scenarios. So, you can check by creating a new user or you can create a new client etc.

Here is a screenshot depicting the events that have been occured.

Admin Events Listing
Admin Events Listing

Here we come to the end of all about Events in Keycloak. If you have any queries, please feel free to put them in comments.

Here is the video for this story for those who want to see everything in action.

Keycloak Events YouTube Video

Those who are new to Keycloak, follow my Getting Started with Keycloak Story here:

Also, there is a detailed video on Keycloak on my YouTube Channel.

Happy Reading :)

--

--

Chandra Sharma
Chandra Sharma

Written by Chandra Sharma

I am a technology explorer who loves to read, hands-on and share the knowledge gained.