Categories:

Table functions (Cortex Agents)

GET_AI_OBSERVABILITY_LOGS (SNOWFLAKE.LOCAL)

Retrieve log data for a Cortex Agent observability event, such as a warning or failure.

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

See also:

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 type of agent to retrieve evaluation data for. Use the string constant CORTEX AGENT. 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

MONITOR

Cortex 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.

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

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';