---
title: "Build a timeline of what happened to the Cloud SQL instance during an incident | Proofline"
description: "Merge four records into one UTC timeline: Cloud SQL operations, Cloud SQL audit logs, the PostgreSQL log, and Cloud Run's audit, system and request logs."
url: https://proofline.sh/learn/cloud-sql-operations-during-incident/
---

[Learning center](/learn/)

# Build a timeline of what happened to the Cloud SQL instance during an incident

Merge four records into one UTC timeline: Cloud SQL operations, Cloud SQL audit logs, the PostgreSQL log, and Cloud Run's audit, system and request logs. The timeline shows what the provider and the control plane recorded; changes made inside the database usually leave no trace in it.

Broken dependencies The Proofline team November 23, 2026 6 min read

## Why one list is not enough

The hub points to `gcloud sql operations list` for the window, and for a single maintenance event or failover that is enough ([where the checks mislead](/learn/cloud-run-cloud-sql-connection-errors/#limits)). In a longer incident, several things happen to the instance and the service, and each record holds a different part:

| Record | Holds | Misses |
| --- | --- | --- |
| Operations list | Each Admin API operation: type, `insertTime`, `startTime`, `endTime`, `status`, `user`, `error` | Actions taken through a database client such as psql |
| Admin Activity audit log | Settings changes, restarts, failovers, CA rotations, with the principal | Data-level calls, and anything Google Cloud does on its own |
| System Event audit log | What Cloud SQL did on its own: automatic failovers, automated backups, automatic storage increases | Anything a person started |
| Data Access audit log | User and login calls, such as `cloudsql.users.update` and `cloudsql.instances.login` | Everything, unless enabled: Data Access logs are off by default |
| PostgreSQL log | Shutdowns, startups, errors, and statements if statement logging is on | The control plane's view |

[Operation resource](https://cloud.google.com/sql/docs/postgres/admin-api/rest/v1/operations) · [Cloud SQL audit logging](https://cloud.google.com/sql/docs/postgres/audit-logging) · [Data Access logs off by default](https://cloud.google.com/logging/docs/audit) · [Instance operations log](https://cloud.google.com/sql/docs/postgres/logging#instance-operations-logs)

## Step 1: the instance's operations

```
gcloud sql operations list --instance INSTANCE --project PROJECT --limit=50 \
  --format='table(operationType, status, insertTime, startTime, endTime, user)'
```

The three times differ in meaning: `insertTime` is when the operation was queued, `startTime` when it began and `endTime` when it finished, all in UTC. An operation can start later than it was queued, so put `startTime` on the timeline. The console's operations pane shows completion time in your local time zone; convert it before merging. [Operation fields](https://cloud.google.com/sql/docs/postgres/admin-api/rest/v1/operations) · [Instance operations log](https://cloud.google.com/sql/docs/postgres/logging#instance-operations-logs)

Most incident-relevant types are `MAINTENANCE`, `FAILOVER`, `AUTO_RESTART`, `RESTART`, `UPDATE` and `UPDATE_USER`. `UPDATE` covers any settings change, including stopping the instance, flag changes and SSL settings. The type does not say which setting changed.

## Step 2: both services' audit logs in one stream

One query reads Cloud SQL's and Cloud Run's Admin Activity and System Event entries in time order. Long-running Cloud SQL methods usually write two entries, one when the operation starts and one when it ends. [Audit log names](https://cloud.google.com/logging/docs/audit) · [Long-running operations](https://cloud.google.com/sql/docs/postgres/audit-logging#permission-type) · [Cloud Run audit logging](https://cloud.google.com/run/docs/audit-logging)

```
gcloud logging read '
  logName=("projects/PROJECT/logs/cloudaudit.googleapis.com%2Factivity"
        OR "projects/PROJECT/logs/cloudaudit.googleapis.com%2Fsystem_event")
  AND protoPayload.serviceName=("cloudsql.googleapis.com" OR "run.googleapis.com")
  AND timestamp>="START_TIME" AND timestamp<="END_TIME"' \
  --project PROJECT --order=asc \
  --format='table(timestamp, protoPayload.serviceName, protoPayload.methodName, protoPayload.authenticationInfo.principalEmail, protoPayload.resourceName)'
```

Admin Activity and System Event logs land in the `_Required` bucket, which keeps them for 400 days. Both are always written. [Logging retention](https://cloud.google.com/logging/quotas) · [High availability](https://cloud.google.com/sql/docs/postgres/high-availability#failover-overview)

## Step 3: the database's own log

The PostgreSQL log places a restart to the second, which the operation's span cannot do:

```
gcloud logging read '
  resource.type="cloudsql_database"
  AND logName="projects/PROJECT/logs/cloudsql.googleapis.com%2Fpostgres.log"
  AND timestamp>="START_TIME" AND timestamp<="END_TIME"' \
  --project PROJECT --order=asc --format='value(timestamp, severity, textPayload)'
```

[View Cloud SQL logs](https://cloud.google.com/sql/docs/postgres/logging)

Statements appear only if the instance logs them. The `log_statement` flag set to `ddl` records DDL, including role changes, and `mod` adds data-modifying statements; its default is `none`. [`log_statement`](https://cloud.google.com/sql/docs/postgres/flags)

## Step 4: the Cloud Run side

Add three events for each revision: when the service update that created it or moved traffic was made (Step 2's `ReplaceService` or `UpdateService` entries), when its instances started (the system log, `varlog/system`, records each start as `Starting new instance` with a reason), and when it served its first request. The `:` operator matches part of the log name, and a bare string searches every field. [Cloud Run logs](https://cloud.google.com/run/docs/logging) · [Logging query language](https://cloud.google.com/logging/docs/view/logging-query-language) · [When did the rollout start serving?](/learn/when-did-the-rollout-start-serving/)

```
gcloud run revisions list --service SERVICE --project PROJECT --region REGION \
  --format='table(metadata.name, metadata.creationTimestamp)'

gcloud logging read '
  resource.type="cloud_run_revision"
  AND resource.labels.service_name="SERVICE"
  AND logName:"varlog"
  AND "Starting new instance"
  AND timestamp>="START_TIME" AND timestamp<="END_TIME"' \
  --project PROJECT --order=asc \
  --format='value(timestamp, resource.labels.revision_name, textPayload)'
```

Instance starts matter because a new instance opens new connections. Many database-side changes, such as a password, an SSL mode or a CA, affect only new connections, so they first show up at the next instance start, whatever caused it.

## A worked fixture: one timeline, one gap

The fixture is illustrative. `orders-api` connects to `orders-db` through the built-in connection. Errors begin at 14:03 UTC.

**Incident A.** The merged timeline:

| Time (UTC) | Source | Event |
| --- | --- | --- |
| 14:02:30 | Admin Activity, Cloud Run | `ReplaceService` by `deployer@shop-prod.iam.gserviceaccount.com`; `orders-api-00018` takes 100% |
| 14:02:41 | Cloud Run `varlog/system` | New `orders-api-00018` instances start |
| 14:03:05 | Admin Activity, Cloud SQL | `cloudsql.instances.restart` by `oncall-b@example.com` |
| 14:03:05 to 14:03:58 | Operations list | `RESTART`, `DONE` |
| 14:03:09 | PostgreSQL log | Shutdown |
| 14:03:12 to 14:03:44 | Cloud Run errors | Both revisions' connections reset or refused |
| 14:03:47 | PostgreSQL log | Ready to accept connections |
| after 14:03:48 | Cloud Run | No errors |

The errors sit inside the restart, start after the shutdown, and end with the startup. The deploy came 35 seconds before and is not involved. The engineer restarted the database while investigating an unrelated alert.

**Incident B.** Same deploy at 14:02:30. From 14:02:52 every new `orders-api-00018` instance fails with `FATAL: password authentication failed for user "orders_app"`, and a fresh `orders-api-00017` instance started through its tag fails the same way. The operations list shows no `UPDATE_USER` that day; the audit stream shows only the Cloud Run update; Data Access logs are off; `log_statement` is `none`.

The timeline is silent where the cause sits. The failure is at the login stage and shared by both revisions, which places it in the database, and no control-plane record shows a password change. That points to a change made from a database client, such as `ALTER ROLE ... PASSWORD`, which the operations list does not record. Ask who holds a privileged database login and compare the password in the secret with the one the user now has. Turning on statement logging to catch the next change has a cost: an `ALTER ROLE` with a plaintext password would be written to the log. A password changed through the Admin API would have appeared as `UPDATE_USER`; [the hub's third incident](/learn/cloud-run-cloud-sql-connection-errors/#worked-fixture) shows that case.

## What the timeline cannot show

It cannot show changes made inside PostgreSQL unless statement logging or pgAudit records them, and it cannot show who logged in unless Data Access logs for Cloud SQL are enabled. Silence in these records is not evidence that nothing changed. [Instance operations log](https://cloud.google.com/sql/docs/postgres/logging#instance-operations-logs) · [Data Access audit logs](https://cloud.google.com/logging/docs/audit)

It cannot show the network between the service and the instance. A path that drops packets leaves no Cloud SQL operation and no audit entry.

It cannot show events outside the project, such as a provider incident in the region. [A cloud provider incident during a rollout](/learn/cloud-provider-incident-during-rollout/) covers that check.

Scheduled maintenance appears in the operations list as `MAINTENANCE`; read the list as well as the audit logs before concluding that nothing happened to the instance. [Maintenance or deploy?](/learn/cloud-sql-maintenance-or-deploy/)

## Questions

### How do I see what happened to a Cloud SQL instance at a given time?

List its operations with `gcloud sql operations list --instance INSTANCE`, read Cloud SQL's Admin Activity and System Event audit logs for the window, and read the PostgreSQL log for shutdowns and startups. Put the three on one UTC timeline.

### Does the Cloud SQL operations list show password changes?

It shows `UPDATE_USER` for changes made through the console, the gcloud CLI or the Admin API. A password changed with a SQL command from a database client does not appear there.

### How long are Cloud SQL audit logs kept?

Admin Activity and System Event audit logs go to the `_Required` bucket, which keeps them for 400 days. Data Access logs are written only if you enable them.

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [Cloud Run cannot reach Cloud SQL: revision, identity or connection?](/learn/cloud-run-cloud-sql-connection-errors/)
    
    Broken dependencies The Proofline team November 23, 2026 10 min read
    
-   ### [Find when an ECS deployment or Cloud Run revision started serving](/learn/when-did-the-rollout-start-serving/)
    
    Deployment failures The Proofline team November 20, 2026 9 min read
