Cortex Analyst administrator monitoring

To improve the quality of answers provided by Cortex Analyst, you must continue to refine the semantic model. To help you refine the model, 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 (passed through the semantic_model_file request body parameter).

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

Use the snowflake.local.cortex_analyst_requests UDTF to retrieve logs for a specific semantic model. This function performs access control checks to ensure the calling user has necessary privileges.

The following is an example of how to use the UDTF:

SELECT * FROM table(SNOWFLAKE.LOCAL.CORTEX_ANALYST_REQUESTS(
  semantic_model_type = 'FILE_ON_STAGE',
  semantic_model_name = '@my_db.my_schema.my_stage/path/to/file.yaml'
));
Copy

Parameters:

  • semantic_model_type: Currently, you can only use FILE_ON_STAGE.

  • semantic_model_name: The fully qualified stage file URL. For example, @my_db.my_schema.my_stage/path/to/file.yaml.

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

If you have 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.

If you have the snowflake.cortex_analyst_requests_admin application role, you can also query raw events from the snowflake.local.cortex_analyst_requests_raw event table. The responses are in the open telemetry format. The snowflake.local.cortex_analyst_requests_v view has the same data as the snowflake.local.cortex_analyst_requests_raw event table, but in a more readable format.