Schema:

ACCOUNT_USAGE

CORTEX_AI_GUARDRAILS_USAGE_HISTORY view

The CORTEX_AI_GUARDRAILS_USAGE_HISTORY view can be used to query the usage history of Cortex AI Guardrails. The view provides visibility into guardrail scan activity, credit consumption, and token usage for each request. Each row in the view represents a single guardrail scan for one tool use within an agent request. A request with multiple tool results produces multiple rows, one per tool use scanned.

Note

This view captures the signals raised by the prompt injection detection guardrails and sent to the LLM for adjudication. The LLM uses those signals to determine whether a request may contain a genuine prompt injection attempt.

Columns

Column NameData TypeDescription
USER_IDNUMBERThe unique identifier of the user who made the request.
USER_NAMEVARCHARThe name of the user who made the request.
USER_TAGSARRAYTags associated with the user. Each object in the array contains the following fields: level (the level at which the tag is applied, for example, ACCOUNT or USER), tag_database, tag_schema, tag_name, and tag_value.
REQUEST_IDVARCHARThe unique identifier for the request.
PARENT_REQUEST_IDVARCHARThe identifier of the parent request, if applicable.
AGENTIC_SOURCEVARCHARThe Cortex client in which guardrails were invoked. Possible values include CORTEX_CODE_CLI, CORTEX_CODE_DESKTOP, CORTEX_CODE_SNOWSIGHT, CORTEX_AGENT, and SNOWFLAKE_INTELLIGENCE.
USAGE_TIMETIMESTAMP_TZThe timestamp when the usage was recorded.
TOKEN_CREDITSNUMBERThe number of token credits consumed for the request.
TOKENSNUMBERThe total number of tokens used for the request.
TOKENS_GRANULAROBJECTGranular breakdown of token usage for the request. Contains the following fields: input, cache_read_input, cache_write_input, and output.
CREDITS_GRANULAROBJECTGranular breakdown of credit usage for the request. Contains the following fields: input, cache_read_input, cache_write_input, and output.
GUARDRAIL_RESULTSARRAYGuardrail scan results. Each object in the array contains: tool_use_id, tool_type (for example, web_search, server_mcp, or sql_execute), optional token fields (input_token, output_token, cache_read_input_token, cache_read_output_token, token_count), and indirect_prompt_injection (whether the scan detected a possible prompt injection for this tool use).
GUARDRAILS_SIGNALBOOLEANIndicates whether any guardrail scan in the request was flagged.
METADATAOBJECTMetadata associated with the request. Contains role_id (the identifier of the role) and role_name (the name of the role).

Examples

Retrieve Cortex AI Guardrails usage history:

SELECT *
  FROM SNOWFLAKE.ACCOUNT_USAGE.CORTEX_AI_GUARDRAILS_USAGE_HISTORY
  WHERE GUARDRAILS_SIGNAL = TRUE;

Usage notes