> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-8a08bda2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> 记录所有成功和失败的登录和登出事件信息的系统表。

# system.session_log

<Info>
  **在 ClickHouse Cloud 中查询**

  此系统表中的数据分别保存在 ClickHouse Cloud 各节点的本地。因此，如需查看所有数据的完整情况，需要使用 `clusterAllReplicas` 函数。更多详情请参见[此处](/zh/reference/system-tables/overview#system-tables-in-clickhouse-cloud)。
</Info>

<div id="description">
  ## 描述
</div>

包含所有成功和失败的登录及登出事件的信息。

<div id="columns">
  ## 列
</div>

* `hostname` ([LowCardinality(String)](/zh/reference/data-types/lowcardinality)) — 执行该查询的服务器主机名。
* `type` ([Enum8('LoginFailure' = 0, 'LoginSuccess' = 1, 'Logout' = 2)](/zh/reference/data-types/enum)) — 登录/登出结果。可能的值：LoginFailure — 登录错误。LoginSuccess — 登录成功。Logout — 从系统登出。
* `auth_id` ([UUID](/zh/reference/data-types/uuid)) — 身份验证 ID，即用户每次登录时自动生成的 UUID。
* `session_id` ([String](/zh/reference/data-types/string)) — 客户端通过 HTTP 接口传递的会话 ID。
* `event_date` ([Date](/zh/reference/data-types/date)) — 登录/登出日期。
* `event_time` ([DateTime](/zh/reference/data-types/datetime)) — 登录/登出时间。
* `event_time_microseconds` ([DateTime64(6)](/zh/reference/data-types/datetime64)) — 精确到微秒的登录/登出开始时间。
* `user` ([Nullable(String)](/zh/reference/data-types/nullable)) — 用户名。
* `auth_type` ([Nullable(Enum8('NO\_PASSWORD' = 0, 'PLAINTEXT\_PASSWORD' = 1, 'SHA256\_PASSWORD' = 2, 'DOUBLE\_SHA1\_PASSWORD' = 3, 'LDAP' = 4, 'KERBEROS' = 5, 'SSL\_CERTIFICATE' = 6, 'BCRYPT\_PASSWORD' = 7, 'SSH\_KEY' = 8, 'HTTP' = 9, 'JWT' = 10, 'SCRAM\_SHA256\_PASSWORD' = 11, 'NO\_AUTHENTICATION' = 12))](/zh/reference/data-types/nullable)) — 身份验证类型。
* `profiles` ([Array(LowCardinality(String))](/zh/reference/data-types/array)) — 为所有角色和/或用户设置的 profile 列表。
* `roles` ([Array(LowCardinality(String))](/zh/reference/data-types/array)) — 应用该 profile 的角色列表。
* `settings` ([Array(Tuple(LowCardinality(String), String))](/zh/reference/data-types/array)) — 客户端登录/登出时更改的设置项。
* `client_address` ([IPv6](/zh/reference/data-types/ipv6)) — 用于登录/登出的 IP 地址。
* `client_port` ([UInt16](/zh/reference/data-types/int-uint)) — 用于登录/登出的客户端端口。
* `interface` ([Enum8('TCP' = 1, 'HTTP' = 2, 'gRPC' = 3, 'MySQL' = 4, 'PostgreSQL' = 5, 'Local' = 6, 'TCP\_Interserver' = 7, 'Prometheus' = 8, 'Background' = 9)](/zh/reference/data-types/enum)) — 发起登录所使用的接口。
* `client_hostname` ([String](/zh/reference/data-types/string)) — 运行 `clickhouse-client` 或其他 TCP 客户端的客户端机器的主机名。
* `client_name` ([String](/zh/reference/data-types/string)) — `clickhouse-client` 或其他 TCP 客户端的名称。
* `client_revision` ([UInt32](/zh/reference/data-types/int-uint)) — `clickhouse-client` 或其他 TCP 客户端的修订版本。
* `client_version_major` ([UInt32](/zh/reference/data-types/int-uint)) — `clickhouse-client` 或其他 TCP 客户端的主版本号。
* `client_version_minor` ([UInt32](/zh/reference/data-types/int-uint)) — `clickhouse-client` 或其他 TCP 客户端的次版本号。
* `client_version_patch` ([UInt32](/zh/reference/data-types/int-uint)) — `clickhouse-client` 或其他 TCP 客户端版本的补丁部分。
* `failure_reason` ([String](/zh/reference/data-types/string)) — 包含登录/登出失败原因的异常消息。

<div id="example">
  ## 示例
</div>

```sql title="Query" theme={null}
SELECT * FROM system.session_log LIMIT 1 FORMAT Vertical;
```

```text title="Response" theme={null}
Row 1:
──────
hostname:                clickhouse.eu-central1.internal
type:                    LoginSuccess
auth_id:                 45e6bd83-b4aa-4a23-85e6-bd83b4aa1a23
session_id:
event_date:              2021-10-14
event_time:              2021-10-14 20:33:52
event_time_microseconds: 2021-10-14 20:33:52.104247
user:                    default
auth_type:               PLAINTEXT_PASSWORD
profiles:                ['default']
roles:                   []
settings:                [('load_balancing','random'),('max_memory_usage','10000000000')]
client_address:          ::ffff:127.0.0.1
client_port:             38490
interface:               TCP
client_hostname:
client_name:             ClickHouse client
client_revision:         54449
client_version_major:    21
client_version_minor:    10
client_version_patch:    0
failure_reason:
```
