- Schema:
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 Name | Data Type | Description |
|---|---|---|
| USER_ID | NUMBER | The unique identifier of the user who made the request. |
| USER_NAME | VARCHAR | The name of the user who made the request. |
| USER_TAGS | ARRAY | Tags 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_ID | VARCHAR | The unique identifier for the request. |
| PARENT_REQUEST_ID | VARCHAR | The identifier of the parent request, if applicable. |
| AGENTIC_SOURCE | VARCHAR | The 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_TIME | TIMESTAMP_TZ | The timestamp when the usage was recorded. |
| TOKEN_CREDITS | NUMBER | The number of token credits consumed for the request. |
| TOKENS | NUMBER | The total number of tokens used for the request. |
| TOKENS_GRANULAR | OBJECT | Granular breakdown of token usage for the request. Contains the following fields: input, cache_read_input, cache_write_input, and output. |
| CREDITS_GRANULAR | OBJECT | Granular breakdown of credit usage for the request. Contains the following fields: input, cache_read_input, cache_write_input, and output. |
| GUARDRAIL_RESULTS | ARRAY | Guardrail 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_SIGNAL | BOOLEAN | Indicates whether any guardrail scan in the request was flagged. |
| METADATA | OBJECT | Metadata 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:
Usage notes¶
- Credit usage is based on the number of tokens scanned, as outlined in the Snowflake Service Consumption Table.
- For information on configuring Cortex AI Guardrails and monitoring guardrail activity, see Cortex AI Guardrails.