Cortex Analyst 管理员监控

为了提高 Cortex Analyst 提供的答案的质量,您必须不断完善语义模型或视图。为帮助您完善模型或视图,Cortex Analyst 会将请求记录到 Snowflake 数据库中的事件表中。

日志包括以下内容:

  • 提出问题的用户

  • 提出的问题

  • 生成的 SQL

  • 错误和/或警告

  • 请求和响应正文

  • 其他元数据

从提出请求到在视图中显示请求之间会存在短暂延迟,大约 1-2 分钟。

访问日志

You can view these logs in the Monitoring tab of the Semantic View within Snowsight. In order to view the logs, users must have the SELECT privilege on referenced tables, in addition to:

  • MONITOR or OWNERSHIP on the semantic view (when using semantic views)

  • WRITE privilege on the stage (for semantic models stored in a file on a stage)

或者,您可以根据自己的权限,使用 SQL 直接从 Snowflake 数据库中查询日志。

使用 SQL 查询日志

调用 SNOWFLAKE.LOCAL.CORTEX_ANALYST_REQUESTS 表函数,检索特定语义模型或视图的日志。此表函数执行访问控制检查,以确保调用者具备访问请求数据所需的权限。

以下示例展示了如何调用此函数:

SELECT * FROM TABLE(
  SNOWFLAKE.LOCAL.CORTEX_ANALYST_REQUESTS(
    '<semantic_model_or_view_type>',
    '<semantic_model_or_view_name>'
  )
);
Copy

调用此函数时,传入以下实参:

  • semantic_model_or_view_type:指定请求中所用语义模型或视图的类型:

    • 对于在暂存区中的文件中定义的语义模型,请指定 'FILE_ON_STAGE'

    • 对于语义视图,请指定 'SEMANTIC_VIEW'

  • semantic_model_or_view_name:指定定义语义模型或视图的位置:

    • For a semantic view defined in a file on a stage, specify the fully qualified path to the semantic view specification file (for example, @my_db.my_schema.my_stage/path/to/file.yaml).

    • 对于语义视图,请指定语义视图的完全限定名称。

返回:包含指定语义模型或视图的所有 API 请求的表。

如果使用行内 YAML(而不是语义视图或暂存区上的文件)进行查询,则无法通过表函数访问该请求,但可以在下文详述的视图和事件表中查看。

If you are using a role that has been granted the SNOWFLAKE.CORTEX_ANALYST_REQUESTS_ADMIN or SNOWFLAKE.CORTEX_ANALYST_REQUESTS_VIEWER application role, you can query the SNOWFLAKE.LOCAL.CORTEX_ANALYST_REQUESTS_V view. This view includes all requests to Cortex Analyst across all semantic models and views.

You can also query the raw event data in the SNOWFLAKE.LOCAL.CORTEX_ANALYST_REQUESTS_RAW event table. The responses are in the OpenTelemetry format (https://opentelemetry.io/docs/specs/otel/). The SNOWFLAKE.LOCAL.CORTEX_ANALYST_REQUESTS_V view contains the same data, formatted and processed for human readability.

语言: 中文