Audit Logging
Your Hydrolix cluster provides you with an API to access authentication activity.
Overview⚓︎
Hydrolix uses Keycloak for authentication. Retrieve authentication events from the HTTP API at https://{myhost}.hydrolix.live/config/v1/auth_logs using the GET action. The endpoint returns a JSON-formatted list of all Keycloak events.
This feature was introduced in Hydrolix version v5.8 where Keycloak authentication events moved from a PostgreSQL-backed database to the Hydrolix hydro.audit_logs table. This change improves performance of audit log reporting for large clusters and decreases contention on the PostgreSQL database system.
Filters⚓︎
Filters can be specified in the request body. These filters include:
-
user_idstring: Includes all Keycloak events that are created by the given user. To return all Keycloak events regardless of user, exclude the field. -
event_typesarray(string): Specifies all the event types to be included in the response. The most useful event types are: -
LOGIN: A user has successfully logged in and has begun a Keycloak session. The sessionId is included in the Keycloak event object. -
LOGIN_ERROR: Someone has tried logging in as the user and failed. The reason for this failure is included in the error field in the event object (invalid_user_credentials,timed_out, and others). -
USER_DISABLED_BY_TEMPORARY_LOCKOUT: A user has been locked out temporarily, with the reason included in the event object. -
USER_DISABLED_BY_PERMANENT_LOCKOUT: A user has been locked out permanently, with the reason included in the event object. -
from_datestring: Excludes all events that occur before the provided time. Should be in the formatYYYY-MM-DD. -
to_datestring: Excludes all events that occur after the provided time. Should be in the formatYYYY-MM-DD. -
from_timestampint: Excludes all events that occur before the provided epoch timestamp in milliseconds. More precise thanfrom_date. -
to_timestampint: Excludes all events that occur after the provided epoch timestamp in milliseconds. More precise thanto_date. -
ip_addressstring: Filters events by the IP address from which the authentication attempt originated. -
usernamestring: Filters events by username. -
target_userstring: Filters events by target user UUID (for actions performed on other users). -
target_usernamestring: Filters events by target username (for actions performed on other users). -
directionstring: Controls the sort order of results by timestamp. Valid values areASC(ascending, oldest first) orDESC(descending, newest first). -
limitint: Limits the number of events returned in the response. The default limit is 100 events.
RBAC permissions⚓︎
API endpoint permissions⚓︎
The /config/v1/auth_logs endpoint is accessible to users with the view_audit permission. By default, only the super_admin role has this permission on cluster startup. Other roles (user_admin, operator, read_only) don't have access by default and must be explicitly granted the view_audit or view_auth_logs_user permission.
Direct table query permissions⚓︎
Users with the select_sql permission for the hydro.audit_logs table can query authentication and audit events directly using SQL. During cluster initialization, users and roles with global view_audit or view_auth_logs_user permissions automatically receive select_sql permission for the hydro.audit_logs table.
Example API call⚓︎
After setting $HDX_TOKEN and $HDX_HOSTNAME, this command will retrieve all the login errors from May 19, 2024 and onward:
Filter by IP address⚓︎
| Filter Authentication Events by IP Address | |
|---|---|
Filter by timestamp range⚓︎
Use epoch timestamps in milliseconds for more precise time filtering:
| Filter by Timestamp Range | |
|---|---|
Query the hydro.audit_logs table directly⚓︎
hydro.audit_logs table schema⚓︎
The hydro.audit_logs table contains both Keycloak authentication events (migrated in v5.8) and audit activity records (migrated in v5.6). Key columns include:
timestamp(datetime): When the event occurredsource(string): Event source (keycloakoraudit)source_id(string): Original event ID from the source systemtype(string): Event type (for example,LOGIN,LOGIN_ERROR,create:job)user_id(string): UUID of the user who performed the actionusername(string): Username of the user who performed the actionsession_id(string): Session identifierip_address(string): IP address from which the action originatedresource_id(string): UUID of the affected resource (for audit events)resource_type(string): Type of affected resource (for audit events). Examples:project,table,transform,job,user,role,policytarget_user_id(string): UUID of user affected by the actiontarget_username(string): Username of user affected by the actionerror(string): Error message (for failed authentication attempts)event_details(string): JSON string with additional event details
Example queries⚓︎
Find all actions by a specific user within a time range:
| Find User Actions by Time Range | |
|---|---|
Find all actions from a specific IP address:
| Find Actions by IP Address | |
|---|---|
Find all users who made changes to a project:
Find authentication activity for a specific user: