Categories:

Table functions (Cortex Agents)

GET_AI_OBSERVABILITY_LOGS (SNOWFLAKE.LOCAL)

Retrieve log data for an AI Observability event, such as a warning or failure, for a Cortex Agent or an External Agent application (see External Agent commands).

Call this function to retrieve information about what events occurred during an evaluation run. For more information, see Cortex Agent evaluations and Observability data.

See also:

GET_AI_OBSERVABILITY_EVENTS (SNOWFLAKE.LOCAL) , GET_AI_RECORD_TRACE (SNOWFLAKE.LOCAL) , GET_AI_EVALUATION_DATA (SNOWFLAKE.LOCAL) , EXECUTE_AI_EVALUATION

Syntax

SNOWFLAKE.LOCAL.GET_AI_OBSERVABILITY_LOGS( <database>, <schema>, <agent_name>, <agent_type> )

Arguments

database

Name of the database containing the agent.

schema

Name of the schema containing the agent.

agent_name

Name of the agent to retrieve a record for.

agent_type

The agent type string. Use CORTEX AGENT for a Cortex Agent evaluation or EXTERNAL AGENT for an External Agent object (see External Agent commands). This value is case-insensitive.

Returns

For details on the information contained in AI Observability events, see Observability data.

Access control requirements

A role used to execute this operation must have the following privileges at a minimum:

Privilege

Object

Notes

CORTEX_USER

Database role

USAGE

Cortex Agent or External Agent

Required on the object identified by agent_name. For EXTERNAL AGENT, USAGE on the External Agent is sufficient to call this function (MONITOR does not apply).

MONITOR

Cortex Agent

Required on the Cortex Agent identified by agent_name when agent_type is CORTEX AGENT. Does not apply when agent_type is EXTERNAL AGENT.

Operating on an object in a schema requires at least one privilege on the parent database and at least one privilege on the parent schema.

For instructions on creating a custom role with a specified set of privileges, see Creating custom roles.

For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.

When agent_type is EXTERNAL AGENT, only USAGE on that object is required to call this function. OWNERSHIP on the External Agent is required to modify or remove the object with ALTER EXTERNAL AGENT or DROP EXTERNAL AGENT.

For the full access control permissions required by Cortex Agent evaluations, see Cortex Agent evaluations – Access control requirements. For External Agent objects, see Observability data.

Examples

The following example checks for errors and warnings for a run called run-1, where the agent is named evaluated_agent stored on the schema eval_db.eval_schema:

SELECT * FROM TABLE(SNOWFLAKE.LOCAL.GET_AI_OBSERVABILITY_LOGS(
  'eval_db',
  'eval_schema',
  'evaluated_agent',
  'CORTEX AGENT')
)
  WHERE TRUE
    AND (record:"severity_text"='ERROR' or record:"severity_text"='WARN')
    AND record_attributes:"snow.ai.observability.run.name"='run-1';