This document provides instructions on how to set up and use Unified Maintenance.
It explains how to enable the Unified Maintenance API, query it directly,
and how to manage maintenance event logs that are automatically sent to
Cloud Logging.

## Enable the Unified Maintenance API

To query the Unified Maintenance API directly, you need to enable the API in your
Google Cloud project. If you want to view maintenance activities for
[App Hub applications](https://docs.cloud.google.com/app-hub/docs/key-concepts.md.txt#application), enable
the API in the management project.

When you enable the API, you can [view your Unified Maintenance events](https://docs.cloud.google.com/hub/docs/maintenance.md.txt) in the Unified Maintenance section of GKE Fleet.


Enable the Maintenance API, if it is not already enabled:


**Roles required to enable APIs**


To enable APIs, you need the `serviceusage.services.enable` permission. If you
created the project, then you likely already have this permission through the
Owner role (`roles/owner`). Otherwise, you can get this permission through the
Service Usage Admin role (`roles/serviceusage.serviceUsageAdmin`).
[Learn how to grant roles](https://docs.cloud.google.com/iam/docs/granting-changing-revoking-access.md.txt).

```bash
gcloud services enable maintenance.googleapis.com
```

> [!NOTE]
> **Note:** Unified Maintenance doesn't display historical events scheduled prior to enabling the API.

## Receive maintenance activity logs in Cloud Logging

The Unified Maintenance service sends maintenance logs automatically (independent of whether the Unified Maintenance API is enabled or not). If you have been granted one of the [basic roles](https://docs.cloud.google.com/iam/docs/roles-overview.md.txt#basic) (Viewer, Editor, or Owner) in Cloud Logging for your project, you have the necessary permissions to access Unified Maintenance logs.

To learn more about the required permissions, see [Access control with IAM](https://docs.cloud.google.com/unified-maintenance/docs/access-control.md.txt).

You cannot deactivate Unified Maintenance, but you can opt out of storing logs.
To opt out, see [Turn off maintenance logs](https://docs.cloud.google.com/unified-maintenance/docs/turn-off-logs-storage.md.txt).

To monitor the resource usage of Unified Maintenance logs in your projects, you can
create a metric-threshold alerting policy. For more information, see [Create metric-threshold alerting policies](https://docs.cloud.google.com/monitoring/alerts/using-alerting-ui.md.txt) in the Google Cloud Observability documentation.

## What's next

- [View maintenance activities](https://docs.cloud.google.com/hub/docs/maintenance.md.txt)
- Log schema [overview](https://docs.cloud.google.com/unified-maintenance/docs/log-schema.md.txt)
- Configure [alerts and notifications](https://docs.cloud.google.com/unified-maintenance/docs/configure-alerts-and-notifications.md.txt)
- Implement [common alert policies](https://docs.cloud.google.com/unified-maintenance/docs/implement-common-alert-policies.md.txt)