設定 Gemini Enterprise 的使用情況稽核記錄

本指南說明管理員如何透過 API 啟用 Gemini Enterprise 的使用情況稽核記錄,以及監控相關記錄。機構可透過使用情況稽核記錄追蹤使用者作業、中繼資料和核心內容,以進行稽核和可觀測性作業。

您可以使用 Gemini Enterprise 應用程式中的ObservabilityConfig設定,管理 Gemini Enterprise 的使用情況稽核。開啟可觀測性後,系統會擷取要求和回應資料 (包括提示和基礎中繼資料),並儲存在 Cloud Logging 中。

事前準備

設定稽核記錄前,請確認您擁有下列 IAM 角色:

  • 如要啟用稽核記錄,您必須具備 Discovery Engine 管理員 IAM 角色 (roles/discoveryengine.admin)。
  • 如要存取 Cloud Logging,您必須擁有記錄檢視者 IAM 角色 (roles/logging.viewer)。

為應用程式啟用使用情況稽核記錄

以下各節說明如何為新應用程式或現有應用程式啟用使用情況稽核記錄。

建立應用程式時開啟使用情況稽核記錄

建立新應用程式時,只要在應用程式建立指令中加入 observabilityConfig 設定,即可啟用使用情況稽核記錄。如要建立新的應用程式,並啟用用量稽核記錄功能,請執行下列指令:

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
  }
}'

更改下列內容:

  • ENDPOINT_LOCATION:API 要求的適用多區域。指定下列其中一個值:
    • 美國多區域:us
    • eu 適用於歐盟多區域
    • global 全球位置
    詳情請參閱「為資料儲存庫指定多區域」。
  • PROJECT_ID:專案 ID。
  • LOCATION:資料儲存庫的多重區域:globaluseu
  • APP_ID:要建立的應用程式 ID。
  • APP_DISPLAY_NAME:要建立的應用程式顯示名稱。

為現有應用程式啟用用量稽核記錄

如要為現有應用程式啟用用量稽核記錄,請執行下列指令:

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
  }
}'

更改下列內容:

  • ENDPOINT_LOCATION:API 要求的適用多區域。指定下列其中一個值:
    • 美國多區域:us
    • eu 適用於歐盟多區域
    • global 全球位置
    詳情請參閱「為資料儲存庫指定多區域」。
  • PROJECT_ID:專案 ID。
  • LOCATION:資料儲存庫的多重區域:globaluseu
  • APP_ID:應用程式 ID。

記錄資訊

下表彙整 Gemini Enterprise 記錄的用量資料:

服務路徑 記錄資料
SearchService.Search

記錄用於建立基準或做為 LLM 輸入內容的來源資料。

要求:
  • query
  • user_info

回覆:
  • attribution_token
  • results.id
AssistantService.Assist

記錄 Gemini Enterprise 助理的要求和回覆。

要求:
  • name
  • query.text
  • query.parts

回覆:
  • assist_token
  • answer.name
  • answer.state
  • answer.replies.grounded_content.text
  • answer.replies.grounded_content.text_grounding_metadata.segments
  • answer.replies.grounded_content.text_grounding_metadata.references
  • answer.skipped_reasons
AssistantService.StreamAssist 要求:
  • name
  • query.text
  • query.parts
  • agents_spec

回覆:
  • assist_token
  • answer.name
  • answer.state
  • answer.replies.grounded_content.text
  • answer.replies.grounded_content.text_grounding_metadata.segments
  • answer.replies.grounded_content.text_grounding_metadata.references
  • answer.skipped_reasons
ConversationSearchService.AnswerQuery 要求:
  • serving_config
  • query.query_id
  • query.text
  • session
  • user_pseudo_id
  • end_user_spec
  • answer_generation_spec.model_spec.model_version
  • answer_generation_spec.prompt_spec.preamble
  • answer_generation_spec.include_citations
  • answer_generation_spec.answer_language_code
  • answer_generation_spec.ignore_adversarial_query
  • answer_generation_spec.ignore_non_answer_seeking_query
  • answer_generation_spec.ignore_jail_breaking_query

回覆:
  • answer
  • answer_query_token
EngineService.CreateEngine 要求:
  • engine_id
  • engine.name
  • engine.create_time
  • engine.display_name
  • engine.update_time
  • engine.data_store_ids
  • engine.data_stores

回覆:
  • engine_id
  • engine.name
  • engine.create_time
  • engine.display_name
  • engine.update_time
  • engine.data_store_ids
  • engine.data_stores
EngineService.UpdateEngine 要求:
  • engine.name
  • engine.create_time
  • engine.display_name
  • engine.update_time
  • engine.data_store_ids
  • engine.data_stores
  • update_mask

回覆:
  • engine.name
  • engine.create_time
  • engine.display_name
  • engine.update_time
  • engine.data_store_ids
  • engine.data_stores
AgentService.SetIamPolicy 要求:
  • policy.bindings.roles
  • policy.bindings.members

回覆:
  • policy.bindings.roles
  • policy.bindings.members
AgentService.CreateAgent 要求:
  • parent
  • agent_id
  • agent.name
  • agent.display_name
  • agent.create_time
  • agent.update_time
  • agent.definition_case

回覆:
  • agent.name
  • agent.display_name
  • agent.create_time
  • agent.update_time
  • agent.definition_case
AgentService.UpdateAgent 要求:
  • agent.name
  • agent.display_name
  • agent.create_time
  • agent.update_time
  • agent.definition_case
  • update_mask

回覆:
  • agent.name
  • agent.display_name
  • agent.create_time
  • agent.update_time
  • agent.definition_case

存取用量記錄

如要存取及查看用量稽核記錄,請按照下列步驟操作:

  1. 前往 Google Cloud 控制台的「Logs Explorer」頁面。

    前往 Logs Explorer

  2. 選取已啟用稽核記錄的 Google Cloud 專案。

  3. 如要只顯示 Gemini Enterprise 記錄,請在查詢編輯器欄位中輸入下列查詢,然後按一下「Run Query」(執行查詢)

      logName="projects/PROJECT_ID/logs/discoveryengine.googleapis.com%2Fgemini_enterprise_user_activity
    

    更改下列內容:

    • PROJECT_ID:專案 ID。

為應用程式停用使用情況稽核記錄

如要關閉用量稽核記錄,請執行下列指令:

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
  }
}'

更改下列內容:

  • ENDPOINT_LOCATION:API 要求的適用多區域。指定下列其中一個值:
    • 美國多區域:us
    • eu 適用於歐盟多區域
    • global 全球位置
    詳情請參閱「為資料儲存庫指定多區域」。
  • PROJECT_ID:專案 ID。
  • LOCATION:資料儲存庫的多重區域:globaluseu
  • APP_ID:應用程式 ID。