Observability

Snowflake AI Observability provides monitoring and tracing capabilities for Cortex Code in Snowsight sessions. You can use it to review prompt history, trace agent execution, attribute credit consumption to individual prompts or sessions.

What’s tracked

Every Cortex Code interaction emits span-level records into the SNOWFLAKE.LOCAL.AI_OBSERVABILITY_EVENTS event table. Each interaction produces two span types:

  • CodingAgentRun: The session-level envelope. One record per conversation turn.
  • CodingAgent.Step-0: An individual model call. Contains the user prompt, model response, token counts, tool selection, latency, and a request_id.

The spans capture conversation history, agent execution steps (LLM planning, tool execution, SQL execution, chart generation, and response generation), the inputs and outputs for each step, and user feedback.

Accessing observability data=

  • SQL. Query the SNOWFLAKE.LOCAL.AI_OBSERVABILITY_EVENTS event table directly. Filter for Cortex Code spans by RECORD:name.

Example: List recent prompts

SELECT
    TIMESTAMP,
    RESOURCE_ATTRIBUTES['snow.user.name']::STRING AS user_name,
    RESOURCE_ATTRIBUTES['snow.session.role.primary.name']::STRING AS role_name,
    RECORD_ATTRIBUTES['snow.ai.observability.agent.planning.model']::STRING AS model,
    RECORD_ATTRIBUTES['snow.ai.observability.agent.planning.duration']::INT AS latency_ms,
    RECORD_ATTRIBUTES['snow.ai.observability.agent.planning.status']::STRING AS status
  FROM SNOWFLAKE.LOCAL.AI_OBSERVABILITY_EVENTS
  WHERE RECORD_TYPE = 'SPAN'
    AND RECORD:name::STRING = 'CodingAgent.Step-0'
  ORDER BY TIMESTAMP DESC;

Cost attribution

To attribute credit consumption to individual prompts, join the event table to CORTEX_CODE_SNOWSIGHT_USAGE_HISTORY on REQUEST_ID:

SELECT
    obs.TIMESTAMP AS event_time,
    obs.RESOURCE_ATTRIBUTES['snow.user.name']::STRING AS user_name,
    obs.RECORD_ATTRIBUTES['snow.ai.observability.agent.planning.model']::STRING AS model,
    usage.TOKEN_CREDITS
  FROM SNOWFLAKE.LOCAL.AI_OBSERVABILITY_EVENTS obs
    JOIN SNOWFLAKE.ACCOUNT_USAGE.CORTEX_CODE_SNOWSIGHT_USAGE_HISTORY usage
      ON obs.RECORD_ATTRIBUTES['snow.ai.observability.agent.planning.request_id']::STRING
         = usage.REQUEST_ID
  WHERE obs.RECORD_TYPE = 'SPAN'
    AND obs.RECORD:name::STRING = 'CodingAgent.Step-0'
  ORDER BY obs.TIMESTAMP DESC;

To attribute cost across a full conversation, group on TRACE['trace_id']:

SELECT
    obs.TRACE['trace_id']::STRING AS session_id,
    obs.RESOURCE_ATTRIBUTES['snow.user.name']::STRING AS user_name,
    COUNT(*) AS total_prompts,
    SUM(usage.TOKEN_CREDITS) AS total_credits
  FROM SNOWFLAKE.LOCAL.AI_OBSERVABILITY_EVENTS obs
    JOIN SNOWFLAKE.ACCOUNT_USAGE.CORTEX_CODE_SNOWSIGHT_USAGE_HISTORY usage
      ON obs.RECORD_ATTRIBUTES['snow.ai.observability.agent.planning.request_id']::STRING
         = usage.REQUEST_ID
  WHERE obs.RECORD_TYPE = 'SPAN'
    AND obs.RECORD:name::STRING = 'CodingAgent.Step-0'
  GROUP BY 1, 2
  ORDER BY total_credits DESC;

Access control

To read observability data, grant the AI_OBSERVABILITY_READER application role:

GRANT APPLICATION ROLE SNOWFLAKE.AI_OBSERVABILITY_READER
  TO ROLE <role_name>;

To manage event retention (DELETE or TRUNCATE), grant SNOWFLAKE.AI_OBSERVABILITY_ADMIN instead.

To join observability data with CORTEX_CODE_SNOWSIGHT_USAGE_HISTORY, the role also needs read access to the SNOWFLAKE database:

GRANT IMPORTED PRIVILEGES ON DATABASE SNOWFLAKE
  TO ROLE <role_name>;

More information

For the full AI Observability reference, including evaluation metrics, tracing, and comparison features, see Snowflake AI Observability Reference.