Monitor Cortex Search requests¶
Cortex Search logs detailed information about search requests for monitoring and debugging purposes. With request logging enabled, you can review query patterns, response times, and request details for a Cortex Search Service.
Information collected in request logs¶
Cortex Search request logs include the following information:
Operation type (for example, QUERY)
Full request body, including query text and parameters
Response status code
Response time in milliseconds
Database, schema, and service name
User, role, and session information
Enable request logging¶
To collect request logs for a Cortex Search Service, enable the REQUEST_LOGGING property on
the service.
You can enable request logging when you create a service:
You can also enable request logging on an existing service:
To disable request logging:
Operational considerations¶
Volume of log data¶
Each logged Cortex Search request produces one event row in
SNOWFLAKE.LOCAL.AI_OBSERVABILITY_EVENTS. How much data you accumulate depends on your request
rate and how long logging stays enabled. Set retention and storage to match the log volume you
expect to keep.
Cost considerations¶
Data stored in SNOWFLAKE.LOCAL tables incurs Snowflake storage charges.
Querying request logs with SQL uses warehouse resources like any other query.
Query latency¶
Enabling request logging does not affect the latency of Cortex Search query requests.
Access Cortex Search request logs¶
The request logs for a Cortex Search Service are stored in the event table SNOWFLAKE.LOCAL.AI_OBSERVABILITY_EVENTS. You can access these logs using a table function or by querying the event table directly.
Using the snowflake.local.get_ai_observability_events function¶
Users with the MONITOR privilege on a Cortex Search Service can view
request logs for that service using the snowflake.local.get_ai_observability_events
function.
Grant MONITOR privilege: Grant the MONITOR privilege on the Cortex Search Service to the role that will use the function:
Query observability events: Call
snowflake.local.get_ai_observability_eventsusing the role with the MONITOR privilege:
Querying the event table as ACCOUNTADMIN¶
Users with the ACCOUNTADMIN role can query the event table directly:
Note
Users with the ACCOUNTADMIN role can query the snowflake.local.ai_observability_events table
and access the request events for all Cortex Search Services in the account.
Access control and permissions¶
To view Cortex Search request logs, users must have one of the following:
OWNERSHIP or MONITOR privilege on the Cortex Search Service
The ACCOUNTADMIN role (for direct event table access)
The following example uses the ACCOUNTADMIN role to create a new role search_monitoring_role
with the required permissions to view Cortex Search request logs:
Output schema¶
The snowflake.local.get_ai_observability_events function returns
a table with the following columns:
Column name |
Data type |
Description |
|---|---|---|
TIMESTAMP |
TIMESTAMP_NTZ(9) |
Time of the event |
START_TIMESTAMP |
TIMESTAMP_NTZ(9) |
Start time of the event (may be NULL) |
TRACE |
OBJECT |
Trace information for the event (may be NULL) |
RESOURCE_ATTRIBUTES |
OBJECT |
Contains session, user, and role information including session ID, user ID, user name, role ID, and role name |
RECORD_TYPE |
STRING |
Type of record, typically ‘EVENT’ for Cortex Search requests |
RECORD |
OBJECT |
Contains the event name, typically ‘CORTEX_SEARCH_REQUEST’ |
RECORD_ATTRIBUTES |
OBJECT |
Contains detailed observability metadata including database, schema, service, user, role, and session information |
VALUE |
VARIANT |
Contains the actual request details including operation type, request body, response status code, and response time |
The VALUE column contains the following key fields:
snow.ai.observability.operation_type: The type of operation, such as ‘QUERY’snow.ai.observability.request_body: The full request including query text and parameterssnow.ai.observability.response_status_code: HTTP status code of the responsesnow.ai.observability.response_time_ms: Response time in millisecondssnow.ai.observability.database.name: Database containing the Cortex Search Servicesnow.ai.observability.schema.name: Schema containing the Cortex Search Servicesnow.ai.observability.object.name: Name of the Cortex Search Service
The following is an example of data found in the VALUE column:
Example¶
Query the request logs for the last 24 hours, using a role with MONITOR privilege on the service.