This guide explains how admins can turn on and monitor usage audit
logging for Gemini Notebook 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 Notebook Enterprise using the
`ObservabilityConfig` settings at the project level. Turning on
observability captures request and response data, including prompts and
grounding metadata, and stores it in Cloud Logging.

> [!NOTE]
> **Note:** Sensitive data isn't filtered out of the audit logs.

## Before you begin

Before configuring audit logs, ensure that you have the following IAM
roles:

- To enable the audit logs, you must have the [Gemini Enterprise Admin](https://docs.cloud.google.com/iam/docs/roles-permissions/discoveryengine.md.txt#discoveryengine.agentspaceAdmin) IAM role (`roles/discoveryengine.agentspaceAdmin`).
- To access Cloud Logging, you must have the [Logs Viewer](https://docs.cloud.google.com/iam/docs/roles-permissions/logging.md.txt#logging.viewer) IAM role (`roles/logging.viewer`).

## Turn on usage audit logging

To turn on usage audit logging, run the following command:

### REST

> [!IMPORTANT]
> **Key Term:** In Gemini Enterprise, the term *app* can be used interchangeably with the term *engine* in the context of APIs. A Gemini Enterprise engine is a generic search engine where the `app_type` field is set to `APP_TYPE_INTRANET`.

```bash
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?updateMask=customerProvidedConfig.notebooklmConfig.observabilityConfig" \
-d '{
  "customerProvidedConfig": {
    "notebooklmConfig": {
      "observabilityConfig": {
        "observabilityEnabled": true,
        "sensitiveLoggingEnabled": true
      }
    }
  }
}'

```

Replace the following:

- `ENDPOINT_LOCATION`: the multi-region for your API request. Specify one of the following values:
  - `us` for the US multi-region
  - `eu` for the EU multi-region
  - `global` for the Global location

  For more information, see [Specify a multi-region
  for your data store](https://docs.cloud.google.com/gemini/enterprise/docs/locations#specify_a_multi-region_for_your_data_store).
- `PROJECT_ID`: the ID of your project.

<br />

## Logged information

The following table summarizes the usage data logged by
Gemini Notebook Enterprise:

| Service Path | Logged data |
|---|---|
| `NotebookService.CreateNotebook` | Request: - `parent` - `notebook.name` Response: <!-- --> - `No response fields are logged.` |
| `NotebookService.ShareNotebook` | Request: - `name` - `account_and_roles` Response: <!-- --> - `No response fields are logged.` |
| `NotebookService.DeleteNotebook` | Request: - `parent` - `names` Response: <!-- --> - `No response fields are logged.` |
| `NotebookService.GetNotebook` | Request: - `name` Response: <!-- --> - `name` - `title` - `cmek_config` |
| `SourceService.BatchCreateSources` | Request: - `parent` Response: <!-- --> - `sources.name` - `sources.source_id.id` - `sources.title` |
| `SourceService.UploadSourceFile` | Request: - `parent` - `blob.filename` - `source_id` Response: <!-- --> - `source_id.id` |
| `NotebookService.InteractSources` | Request: - `name` - `input_sources` - `free_form_action` Response: <!-- --> - `response.response` - `response.empty_answer_reason` - `response.citations.text` - `response.inline_citations.answer_citation_location` - `response.inline_citations.citations_reference` |
| `NotebookService.GenerateFreeFormStreamed` | Request: - `name` - `sources` - `user_query` Response: <!-- --> - `answer.response` - `answer.empty_answer_reason` - `citations.text` - `inline_citations.answer_citation_location` - `inline_citations.citations_reference` - `suggested_questions` |

## Access usage logs

To view the usage audit logs for Gemini Notebook Enterprise:

1. In the Google Cloud console, go to the **Logs Explorer** page.

   [Go to Logs Explorer](https://console.cloud.google.com/logs/query)
2. Select the Google Cloud project for which you enabled audit logging.

3. To show only Gemini Notebook Enterprise logs, enter the following query
   in the query editor field, and click **Run Query**:

   ```sql
   logName="projects/<var>PROJECT_ID</var>/logs/discoveryengine.googleapis.com%2Fnotebooklm_enterprise_user_activity"
   ```

   Replace the following:
   - `PROJECT_ID`: the ID of your project.

## Turn off usage audit logs

To turn off usage audit logging, run the following command:

### REST

> [!IMPORTANT]
> **Key Term:** In Gemini Enterprise, the term *app* can be used interchangeably with the term *engine* in the context of APIs. A Gemini Enterprise engine is a generic search engine where the `app_type` field is set to `APP_TYPE_INTRANET`.

```bash
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?updateMask=customerProvidedConfig.notebooklmConfig.observabilityConfig" \
-d '{
  "customerProvidedConfig": {
    "notebooklmConfig": {
      "observabilityConfig": {
        "observabilityEnabled": false,
        "sensitiveLoggingEnabled": false
      }
    }
  }
}'
```

Replace the following:

- `ENDPOINT_LOCATION`: the multi-region for your API request. Specify one of the following values:
  - `us` for the US multi-region
  - `eu` for the EU multi-region
  - `global` for the Global location

  For more information, see [Specify a multi-region
  for your data store](https://docs.cloud.google.com/gemini/enterprise/docs/locations#specify_a_multi-region_for_your_data_store).
- `PROJECT_ID`: the ID of your project.

<br />