Cortex Analyst administrator monitoring¶

To improve the quality of answers provided by Cortex Analyst, you must continue to refine the semantic model or view. To help you refine the model or view, Cortex Analyst logs requests to an event table in the Snowflake database.

This feature is currently only available for semantic models stored in a stage (specified in the body of the request by the semantic_model_file field) and semantic views (specified in the semantic_view field).

The logs include the following:

  • The user who asked the question

  • The question asked

  • Generated SQL

  • Errors and/or warnings

  • Request and response bodies

  • Other metadata

Accessing logs¶

You can view these logs in the Monitoring tab of the Semantic Model within Snowsight. Users must have the WRITE privilege on the stage and the SELECT privilege on referenced tables to view the logs.

Alternatively, you can query the logs directly from the Snowflake database using SQL, depending on your privileges.

Querying logs with SQL¶

Call the SNOWFLAKE.LOCAL.CORTEX_ANALYST_REQUESTS table function to retrieve logs for a specific semantic model or view. This table function performs access control checks to ensure that the caller has required privileges to access the request data.

The following is an example of how to call the function:

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

When calling this function, pass in the following arguments:

  • semantic_model_or_view_type: Specify the type of semantic model or view used in the requests:

    • For a semantic model defined in a file on a stage, specify 'FILE_ON_STAGE'.

    • For a semantic view, specify 'SEMANTIC_VIEW'.

  • semantic_model_or_view_name: Specify the location where the semantic model or view is defined:

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

    • For a semantic view, specify the fully qualified name of the semantic view.

Returns: A table with all API requests for the specified semantic model or view.

If you are using a role that has been granted the SNOWFLAKE.CORTEX_ANALYST_REQUESTS_ADMIN 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 open telemetry format. Note that the SNOWFLAKE.LOCAL.CORTEX_ANALYST_REQUESTS_V view contains the same data in a more readable format.