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:
|
AgentService.CreateAgentRequest |
Request:
Response:
|
GroundedGenerationService.GenerateGroundedContent |
Request:
Response:
|
DataConnectorService.UpdateDataConnector |
Request:
Response:
|
AssistantService.AddContextFile |
Request:
Response:
|
AssistantService.UploadSessionFile |
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_activity" OR logName=~"projects/PROJECT_ID/logs/discoveryengine.googleapis.com%2Fgen_ai.*"Replace the following:
PROJECT_ID: the ID of your project.
Control access to logs
You can control access to the logs in Cloud Logging. For detailed guidance on access control methods, including using IAM conditions for fine-grained access, see Access control with IAM.
Default access control
By default, Gemini Enterprise sends Cloud Logging data to the _Default
bucket. The following IAM roles control access to this bucket:
Logs Viewer role (
roles/logging.viewer)Private Logs Viewer role (
roles/logging.privateLogViewer)Logs View Accessor role (
roles/logging.viewAccessor)
Fine-grained access control
If your project contains logs with varying sensitivity levels, you can use several Google Cloud and Cloud Logging tools to configure more fine-grained access control.
You can configure fine-grained access control using the following options:
| Option | Description |
|---|---|
| IAM conditions | Set up fine-grained access control using IAM conditions. For more information, see Logging roles. |
| Log views | Use log views to limit user access to a subset of logs within a log bucket. For more information, see Configure log views on a log bucket. |
| Log sinks | Use log sinks to route sensitive logs to a separate project with more restrictive IAM access. For more information, see Route logs to supported destinations. |
| Tags | Use tags to manage IAM access to individual log buckets within a project. For more information, see Use tags to manage access to log buckets. |
| Field-level access control | Use field-level access control to hide or restrict access to specific fields within log entries. For more information, see Configure field-level access. |
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.