LOGIN_HISTORY

functionsupportedAccounts, users, sessions, warehouses

docs.snowflake.com ↗

Information SchemaTable functions

The LOGIN_HISTORY family of table functions can be used to query login attempts by Snowflake users along various dimensions: - LOGIN_HISTORY returns login events within a specified time range. - LOGIN_HISTORY_BY_USER returns login events of a specified user within a specified time range. Each function is optimized for querying along the specified dimension. The results can be further filtered using SQL predicates. Note These functions return login activity within the last 7 days.

Syntax

supportedpartialnot supportednot scored

LOGIN_HISTORY(
      [  TIME_RANGE_START => <constant_expr> ]
      [, TIME_RANGE_END => <constant_expr> ]
      [, RESULT_LIMIT => <num> ] )

LOGIN_HISTORY_BY_USER(
      [  USER_NAME => '<string>' ]
      [, TIME_RANGE_START => <constant_expr> ]
      [, TIME_RANGE_END => <constant_expr> ]
      [, RESULT_LIMIT => <num> ] )

Parameters

NameRequiredDescription
TIME_RANGE_START => constant_expr , TIME_RANGE_END => constant_exprrequiredTime range (in TIMESTAMP_LTZ format), within the last 7 days, in which the login event occurred. If TIME_RANGE_END is not specified, the function returns the most recent login events. If the time range does not fall within the last 7 days, an error is returned.
USER_NAME => 'string'requiredApplies only to LOGIN_HISTORY_BY_USER A string specifying a user name or CURRENT_USER. Only login events for the specified user are returned. Note that the login name must be enclosed in single quotes. Also, if the login name contains any spaces, mixed-case characters, or special characters, the name must be double-quoted within the single quotes (e.g. '"User 1"' vs 'user1'). Default: CURRENT_USER
RESULT_LIMIT => numrequiredA number specifying the maximum number of rows returned by the function. If the number of matching rows is greater than this limit, the login events with the most recent timestamp are returned, up to the specified limit. Range: 1 to 10000 Default: 100.

Usage notes

Output

The function returns the following columns: Column Name | Data Type | Description EVENT_TIMESTAMP | TIMESTAMP_LTZ | Time of the event occurrence. EVENT_ID | NUMBER | Event’s unique id. EVENT_TYPE | VARCHAR | Event type, such as LOGIN for authentication events. USER_NAME | VARCHAR | User associated with this event. If the user could not be identified during a failed authentication attempt, this value is NULL. CLIENT_IP | VARCHAR | IP address where the request originated from. REPORTED_CLIENT_TYPE | VARCHAR | Reported type of the client software, such as JDBC_DRIVER, ODBC_DRIVER, etc. This information is not authenticated. REPORTED_CLIENT_VERSION | VARCHAR | Reported version of the client software. This information is not authenticated. FIRST_AUTHENTICATION_FACTOR | VARCHAR | Method used to authenticate the user (the first factor in multi factor authentication, if used). SECOND_AUTHENTICATION_FACTOR | VARCHAR | The second factor in multi factor authentication. If the user did not use multi-factor authentication, this value is NULL. IS_SUCCESS | VARCHAR | Whether the user’s request was successful or not. ERROR_CODE | NUMBER | Error code, if the request was not successful. ERROR_MESSAGE | VARCHAR | Error message returned to the user, if the request was not successful. RELATED_EVENT_ID | NUMBER | Reserved for future use. CONNECTION | VARCHAR | Name of the connection used by the client, or NULL if the client is not using a connection URL. Connection is a Snowflake object that is a part of Client Redirect. It represents a connection URL that you can use to fail over to another account for business continuity and disaster recovery. NOTE: If a client authenticates through an identity provider (IdP) that is configured with the account URL rather than the connection URL, the IdP directs the client to the account URL after authentication is complete. The CONNECTION column for this login event is NULL. See Authentication and Client Redirect. CLIENT_PRIVATE_LINK_ID | VARCHAR | If the user logged in using private connectivity, specifies the identifier of the endpoint from which the request originated. FIRST_AUTHENTICATION_FACTOR_ID | VARCHAR | ID of the credential used to authenticate the user (the first factor in multi-factor authentication, if used). SECOND_AUTHENTICATION_FACTOR_ID | VARCHAR | ID of the credential used for the second factor in multi-factor authentication. If the user did not use multi-factor authentication, this value is NULL. LOGIN_DETAILS | VARCHAR | A JSON object containing details for each login event, including the malicious IP protection category name, the risk category, and the blocking status. For failed authentication attempts with validation errors, the object also includes authn_validation_error, a JSON array of strings describing the validation errors. For example, ["Audience mismatch: expected 'https://account.snowflakecomputing.com', got 'https://other.example.com'"]. AUTHORIZING_INTEGRATION_NAME | VARCHAR | Name of the security integration that authorized the login. For OAuth logins, this is the security integration used to grant access. If no security integration authorized the login, this value is NULL. AUTHENTICATING_INTEGRATION_NAME | VARCHAR | Name of the security integration used for authentication. For federated logins, this is the SAML or OIDC security integration. If no security integration was used for authentication, this value is NULL. For details about the error codes/messages for login attempts that were unsuccessful due to invalid SAML responses, see Federated authentication and SSO troubleshooting.