This guide explains how admins can turn on and monitor usage audit logging for Gemini Enterprise through the API. Usage audit logs let organizations track user operations, metadata, and core content for auditing and observability purposes.
You can manage usage auditing for Gemini Enterprise using the
ObservabilityConfig settings in the Gemini Enterprise app. Turning on
observability captures request and response data, including prompts and
grounding metadata, and stores it in Cloud Logging.
Before you begin
Before configuring audit logs, ensure that you have the following IAM roles:
- To turn on the audit logging, you must have the
Discovery Engine Admin
IAM role (
roles/discoveryengine.admin). - To access Cloud Logging, you must have the
Logs Viewer
IAM role (
roles/logging.viewer).
Turn on usage audit logging for apps
The following sections describe how to turn on usage audit logging when creating a new app or for an existing app.
Turn on usage audit logging when creating an app
You can turn on usage audit logging when creating a new app by including the
observabilityConfig settings in the app creation command. To create a new app
with usage audit logging turned on, run the following command:
REST
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
-H "X-Goog-User-Project: PROJECT_ID" \
"https://ENDPOINT_LOCATION-discoveryengine.googleapis.com/v1alpha/projects/PROJECT_ID/locations/LOCATION/collections/default_collection/engines?engineId=APP_ID" \
-d '{
"name": "projects/PROJECT_ID/locations/LOCATION/collections/default_collection/engines/APP_ID",
"displayName": "APP_DISPLAY_NAME",
"solutionType": "SOLUTION_TYPE_SEARCH",
"searchEngineConfig": {
"searchTier": "SEARCH_TIER_ENTERPRISE",
"searchAddOns": ["SEARCH_ADD_ON_LLM"],
"requiredSubscriptionTier": "SUBSCRIPTION_TIER_SEARCH_AND_ASSISTANT"
},
"industryVertical": "GENERIC",
"appType": "APP_TYPE_INTRANET",
"observabilityConfig": {
"observabilityEnabled": true,
"sensitiveLoggingEnabled": true
}
}'
Replace the following:
ENDPOINT_LOCATION: the multi-region for your API request. Specify one of the following values:usfor the US multi-regioneufor the EU multi-regionglobalfor the Global location
PROJECT_ID: the ID of your project.LOCATION: the multi-region of your data store:global,us, oreuAPP_ID: the ID of the app that you want to create.APP_DISPLAY_NAME: the display name of the app that you want to create.
Turn on usage audit logging for an existing app
To turn on usage audit logging on an existing app, run the following command:
REST
curl -X PATCH -H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
-H "X-Goog-User-Project: PROJECT_ID" \
"https://ENDPOINT_LOCATION-discoveryengine.googleapis.com/v1alpha/projects/PROJECT_ID/locations/LOCATION/collections/default_collection/engines/APP_ID?updateMask=observabilityConfig" \
-d '{
"observabilityConfig": {
"observabilityEnabled": true,
"sensitiveLoggingEnabled": true
}
}'
Replace the following:
ENDPOINT_LOCATION: the multi-region for your API request. Specify one of the following values:usfor the US multi-regioneufor the EU multi-regionglobalfor the Global location
PROJECT_ID: the ID of your project.LOCATION: the multi-region of your data store:global,us, oreuAPP_ID: the ID of the app.
Logged information
The following table summarizes the usage data logged by Gemini Enterprise:
| Service path | Logged data |
|---|---|
SearchService.Search |
Logs the data on the sources used for grounding or as LLM input. Request:
Response:
|
AssistantService.Assist |
Logs the request and response from the Gemini Enterprise assistant. Request:
Response:
|
AssistantService.StreamAssist |
Request:
Response:
|
ConversationSearchService.AnswerQuery |
Request:
Response:
|
EngineService.CreateEngine |
Request:
Response:
|
EngineService.UpdateEngine |
Request:
Response:
|
AgentService.SetIamPolicy |
Request:
Response:
|
AgentService.CreateAgent |
Request:
Response:
|
AgentService.UpdateAgent |
Request:
Response:
|
Access usage logs
To access and view the usage audit logs, follow these steps:
In the Google Cloud console, go to the Logs Explorer page.
Select the Google Cloud project for which you enabled audit logging.
To show only Gemini Enterprise logs, enter the following query in the query editor field, and click Run Query:
logName="projects/PROJECT_ID/logs/discoveryengine.googleapis.com%2Fgemini_enterprise_user_activityReplace the following:
PROJECT_ID: the ID of your project.
Turn off usage audit logs for an app
To turn off usage audit logging, run the following command:
REST
curl -X PATCH -H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
-H "X-Goog-User-Project: PROJECT_ID" \
"https://ENDPOINT_LOCATION-discoveryengine.googleapis.com/v1alpha/projects/PROJECT_ID/locations/LOCATION/collections/default_collection/engines/APP_ID?updateMask=observabilityConfig" \
-d '{
"observabilityConfig": {
"observabilityEnabled": false,
"sensitiveLoggingEnabled": false
}
}'
Replace the following:
ENDPOINT_LOCATION: the multi-region for your API request. Specify one of the following values:usfor the US multi-regioneufor the EU multi-regionglobalfor the Global location
PROJECT_ID: the ID of your project.LOCATION: the multi-region of your data store:global,us, oreuAPP_ID: the ID of the app.