snow logs¶
检索给定对象的日志。
语法¶
snow logs
<object_type>
<object_name>
--from <from_>
--to <to>
--refresh <refresh_time>
--table <event_table>
--log-level <log_level>
--partial
--connection <connection>
--host <host>
--port <port>
--account <account>
--user <user>
--password <password>
--authenticator <authenticator>
--workload-identity-provider <workload_identity_provider>
--private-key-file <private_key_file>
--token <token>
--token-file-path <token_file_path>
--database <database>
--schema <schema>
--role <role>
--warehouse <warehouse>
--temporary-connection
--mfa-passcode <mfa_passcode>
--enable-diag
--diag-log-path <diag_log_path>
--diag-allowlist-path <diag_allowlist_path>
--oauth-client-id <oauth_client_id>
--oauth-client-secret <oauth_client_secret>
--oauth-authorization-url <oauth_authorization_url>
--oauth-token-request-url <oauth_token_request_url>
--oauth-redirect-uri <oauth_redirect_uri>
--oauth-scope <oauth_scope>
--oauth-disable-pkce
--oauth-enable-refresh-tokens
--oauth-enable-single-use-refresh-tokens
--client-store-temporary-credential
--format <format>
--verbose
--debug
--silent
--enhanced-exit-codes
实参¶
object_type对象类型。例如表、数据库、计算池。
object_name对象名称。
选项¶
--from TEXT要检索日志的开始时间。接受所有 ISO8061 格式。
--to TEXT要检索日志的结束时间。接受所有 ISO8061 格式。
--refresh INTEGER如果已设置,日志将以指定的刷新时间(单位为秒)进行流式传输。
--table TEXT用于查询日志的表。如果未提供,则将使用默认表。
--log-level TEXT用于筛选的日志级别。如果未提供,则将使用 INFO。默认:INFO。
--partial启用对象名称的部分匹配,不区分大小写。默认值:None。False。
--connection, -c, --environment TEXT连接名称,如您在
config.toml文件中所定义。默认值:default。--host TEXT连接的主机地址。替换为连接指定的值。
--port INTEGER连接的端口。替换为连接指定的值。
--account, --accountname TEXT分配给 Snowflake 账户的名称。替换为连接指定的值。
--user, --username TEXT连接到 Snowflake 的用户名。替换为连接指定的值。
--password TEXTSnowflake 密码。替换为连接指定的值。
--authenticator TEXTSnowflake 身份验证器。替换为连接指定的值。
--workload-identity-provider TEXTWorkload identity provider (AWS, AZURE, GCP, OIDC). Overrides the value specified for the connection.
--private-key-file, --private-key-path TEXTSnowflake 私钥文件路径。替换为连接指定的值。
--token TEXT连接到 Snowflake 时使用的 OAuth 令牌。
--token-file-path TEXT连接到 Snowflake 时使用的带有 OAuth 令牌的文件路径。
--database, --dbname TEXT要使用的数据库。替换为连接指定的值。
--schema, --schemaname TEXT要使用的数据库架构。替换为连接指定的值。
--role, --rolename TEXT要使用的角色。替换为连接指定的值。
--warehouse TEXT要使用的仓库。替换为连接指定的值。
--temporary-connection, -x使用命令行参数定义的连接,而不是在配置中定义的连接。默认值:False。
--mfa-passcode TEXT用于多重身份验证的令牌 (MFA)。
--enable-diag是否生成连接诊断报告。默认值:False。
--diag-log-path TEXT生成的报告的路径。默认为系统临时目录。默认:<system_temporary_directory>。
--diag-allowlist-path TEXT包含允许列表参数的 JSON 文件的路径。
--oauth-client-id TEXT身份提供商为 Snowflake 集成提供的客户端 ID 的值。
--oauth-client-secret TEXT身份提供商为 Snowflake 集成提供的客户端密钥的值。
--oauth-authorization-url TEXT向驱动程序提供授权码的身份提供商端点。
--oauth-token-request-url TEXT向驱动程序提供访问令牌的身份提供商端点。
--oauth-redirect-uri TEXTURI 用于授权码重定向。
--oauth-scope TEXT身份提供商授权请求中请求的范围。
--oauth-disable-pkce禁用代码交换证明密钥 (PKCE)。默认值:
False。--oauth-enable-refresh-tokens在实际访问令牌过期时启用静默重新身份验证。默认值:
False。--oauth-enable-single-use-refresh-tokens是否选择启用一次性刷新令牌语义。默认值:
False。--client-store-temporary-credential存储临时凭据。
--format [TABLE|JSON|JSON_EXT|CSV]指定输出格式。默认:TABLE。
--verbose, -v显示日志级别
info及更高级别的日志条目。默认值:False。--debug显示日志级别
debug及更高级别的日志条目;调试日志包含其他信息。默认值:False。--silent关闭到控制台的中间输出。默认值:False。
--enhanced-exit-codes根据错误类型区分退出错误代码。默认值:False。
--help显示此命令的帮助文本。
使用说明¶
The snow logs command accesses an event table and retrieves logs for a specified entity. By default, the command looks for
the logs in the default event table, which is SNOWFLAKE.TELEMETRY.EVENTS; however, you can select a different table with the
--table option. For more information about event tables and default values, see 创建事件表.
您可以使用 --from 和 -to 选项来筛选检索日志的时间段。您可以使用其中一个或两个选项,但如果您同时使用这两个选项,则 --from 时间必须早于 --to 时间。您提供的时间值必须符合 ISO 8601 标准 (https://www.iso.org/iso-8601-date-and-time-format.html)。有关更多信息,您还可以查看 Python datetime.fromisoformat() (https://docs.python.org/3/library/datetime.html#datetime.datetime.fromisoformat) 方法文档。
The --log-level 选项允许您按 严重性级别 <label-event_table_schema>`筛选消息。某些日志不包含严重性级别。在这种情况下,系统将显示所有:codenowrap:--log-level` 值的消息。
--partial 选项允许您以不区分大小写的方式检索包含特定字符串的日志。例如,如果使用此选项搜索包含 myDb 的日志,结果将包括名为 mydb、 MYDB 和 MyDb 的数据库的日志。如果不使用此选项,则仅返回名称完全为 myDb 的数据库日志。
如果您想持续更新日志,则可以使用 --refresh 选项并提供两次检索之间的秒数。您无法同时使用codenowrap:--refresh 和 --to 选项。要停止日志的流式传输,请在 Mac 终端中使用系统默认的 Keyboardinterrupt 键,例如 CTRL-c。
示例¶
显示从指定开始时间到现在的一段时间内的计算池日志:
snow logs compute_pool MY_COMPUTE_POOL --from '2025-04-01 09:00:31'
10.12.71.201 - - [01/Apr/2025 09:46:07] "GET /healthcheck HTTP/1.1" 200 - 10.12.71.201 - - [01/Apr/2025 09:46:09] "GET /healthcheck HTTP/1.1" 200 - 10.12.71.201 - - [01/Apr/2025 09:46:14] "GET /healthcheck HTTP/1.1" 200 - 10.12.71.201 - - [01/Apr/2025 09:46:19] "GET /healthcheck HTTP/1.1" 200 - 10.12.71.201 - - [01/Apr/2025 09:46:24] "GET /healthcheck HTTP/1.1" 200 - 10.12.71.201 - - [01/Apr/2025 09:46:29] "GET /healthcheck HTTP/1.1" 200 - 10.12.71.201 - - [01/Apr/2025 09:46:34] "GET /healthcheck HTTP/1.1" 200 -
显示特定事件表的日志:
snow logs compute_pool SNOWCLI_COMPUTE_POOL --table "my_db.my_schema.my_events"
显示所有包含
myDb的数据库日志,使用不区分大小写的部分匹配:snow logs database myDb --partial
显示开始时间晚于结束时间的时间范围内的日志,这会导致错误:
snow logs compute_pool SNOWCLI_COMPUTE_POOL --from '2025-03-24 12:00:31' --to "2024-01-03 00:00:00"
╭─ Error ───────────────────────────────────────────────────────── │ From_time cannot be later than to_time. Please check the values ╰─────────────────────────────────────────────────────────────────