Auf dieser Seite wird beschrieben, wie Sie ein Audit-Log für eine automatische Sicherung Ihrer Cloud SQL-Instanz aufrufen.
Mit Audit-Logs können Sie Folgendes tun:
Prüfen Sie anhand eines Audit-Logs, ob die Sicherung erfolgreich abgeschlossen wurde.
Konfigurieren Sie eine logbasierte Benachrichtigung, damit Sie über den Status der Sicherung informiert werden.
Audit-Log aufrufen
Sie können die Google Cloud Konsole, gcloud CLI oder die API verwenden, um ein Audit-Log aufzurufen und zu prüfen, ob eine Sicherung innerhalb eines Sicherungsfensters erfolgreich abgeschlossen wurde.
Konsole
Wählen Sie in der Google Cloud -Console Logging und dann Log-Explorer aus.
Ersetzen Sie PROJECT_ID durch die ID Ihres Google Cloud Projekts.
Der erste Ausdruck filtert nach Audit-Logs zu Systemereignissen.
Der zweite Ausdruck filtert nach Audit-Logs für automatische Sicherungen. Der letzte Ausdruck filtert nach Audit-Logs für Cloud SQL-Instanzen.
Weitere Informationen zur Abfrage von Audit-Logs mit der Google Cloud Console finden Sie unter Logs ansehen.
Rufen Sie den Status einer Sicherung auf, die während des Sicherungszeitraums erstellt wurde. Dieser Status wird im Feld windowStatus angezeigt. Führen Sie die folgenden Schritte aus, um dieses Feld aufzurufen:
Klicken Sie auf das Audit-Log.
Klicken Sie auf das Feld metadata.
gcloud
Führen Sie die folgende Abfrage aus, um nach Audit-Logs für automatische Sicherungen von Cloud SQL-Instanzen zu filtern:
Ersetzen Sie PROJECT_NAME durch den Namen Ihres Google Cloud Projekts.
Der erste Ausdruck filtert nach Audit-Logs zu Systemereignissen.
Der zweite Ausdruck filtert nach Audit-Logs für automatische Sicherungen. Der letzte Ausdruck filtert nach Audit-Logs für Cloud SQL-Instanzen.
Weitere Informationen zur Abfrage von Audit-Logs mit gcloud finden Sie unter Logs ansehen.
Rufen Sie den Status einer Sicherung auf, die während des Sicherungszeitraums erstellt wurde. Dieser Status wird im Feld windowStatus angezeigt.
API
Ersetzen Sie diese Werte in den folgenden Anfragedaten:
PROJECT_ID: Die ID Ihres Google Cloud -Projekts.
Für den JSON-Text der Anfrage filtert der erste Ausdruck nach Audit-Logs zu Systemereignissen. Der zweite Ausdruck filtert Audit-Logs für automatische Sicherungen.
Der letzte Ausdruck filtert Audit-Logs für Cloud SQL-Instanzen.
Weitere Informationen zur Verwendung der API zum Abfragen von Audit-Logs finden Sie unter Logs ansehen.
HTTP-Methode und URL:
POST https://logging.googleapis.com/v2/entries:list
JSON-Text anfordern:
{
"resourceNames": [
"projects/PROJECT_ID"
],
"pageSize": 5,
"filter": "logName=projects/PROJECT_ID/logs/cloudaudit.googleapis.com%2Fsystem_event AND protoPayload.methodName = cloudsql.instances.automatedBackup AND resource.type=cloudsql_database",
"orderBy": "timestamp desc"
}
Wenn Sie die Anfrage senden möchten, maximieren Sie eine der folgenden Optionen:
curl (Linux, macOS oder Cloud Shell)
Speichern Sie den Anfragetext in einer Datei mit dem Namen request.json und führen Sie den folgenden Befehl aus:
Weitere Informationen zu LOG_ENTRY_UNIQUE_IDENTIFIER für das Feld insertId finden Sie unter LogEntry.
Rufen Sie den Status einer Sicherung auf, die während des Sicherungszeitraums erstellt wurde. Dieser Status wird im Feld windowStatus angezeigt.
Status der automatischen Sicherung
STATUS_SUCCEEDED: Die automatische Sicherung wurde erfolgreich abgeschlossen.
STATUS_ATTEMPT_FAILED: Cloud SQL hat versucht, die Sicherung zu erstellen, aber die Sicherung wurde nicht gestartet oder ist fehlgeschlagen. Gründe für diesen Status:
Auf der Instanz wird eine andere Sicherung ausgeführt.
Der Speicherort für die Sicherung ist durch Ihre Organisationsrichtlinie eingeschränkt.
Die Sicherung der Instanz ist abgeschlossen, aber ein Fehler ist aufgetreten.
Die Instanz wurde nicht ausgeführt, als Cloud SQL versuchte, die Sicherung zu erstellen.
STATUS_FAILED: Die automatische Sicherung der Instanz wurde entweder nicht erfolgreich abgeschlossen oder kann nicht im Sicherungszeitraum abgeschlossen werden.
Wenn Sie beispielsweise automatische Sicherungen aktiviert und den Sicherungszeitraum zwischen 01:00 und 05:00 Uhr geplant haben, kann die Sicherung fehlschlagen, wenn während dieser Zeit viele EXPORT-Vorgänge ausgeführt werden.
Automatische Sicherungen können auch fehlschlagen, wenn zu viele Konflikte mit einem EXPORT-Vorgang auftreten, der über einen längeren Zeitraum ausgeführt wird.
Wenn Cloud SQL während eines Sicherungsfensters mehrmals eine Sicherung erstellt, aber die Sicherung aus den aufgelisteten Gründen nicht für STATUS_ATTEMPT_FAILED erstellt werden kann, erstellt Cloud SQL ein weiteres Audit-Log mit dem Feld windowStatus auf STATUS_FAILED.
STATUS_SKIPPED: Die Cloud SQL-Instanz wurde seit der letzten erfolgreichen Sicherung nicht mehr ausgeführt. Daher wurde keine neue automatische Sicherung erstellt.
Wenn eine Sicherung den Status STATUS_SUCCEEDED hat, können Sie zu Tracking-Zwecken benachrichtigt werden.
Wenn eine Sicherung den Status STATUS_FAILED oder STATUS_ATTEMPT_FAILED hat, können Sie basierend auf der im Logeintrag angezeigten Nachricht informiert werden, um Korrekturmaßnahmen zu ergreifen. Sie können auch vor dem nächsten geplanten Sicherungsfenster eine On-Demand-Sicherung erstellen.
Wenn eine Sicherung den Status STATUS_SKIPPED hat, können Sie benachrichtigt werden, um die Cloud SQL-Instanz neu zu starten.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-09 (UTC)."],[],[],null,["\u003cbr /\u003e\n\n[MySQL](/sql/docs/mysql/backup-recovery/view-audit-logs-for-automated-backups \"View this page for the MySQL database engine\") \\| [PostgreSQL](/sql/docs/postgres/backup-recovery/view-audit-logs-for-automated-backups \"View this page for the PostgreSQL database engine\") \\| SQL Server\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nThis page describes how to view an audit log for an automated backup of your\nCloud SQL instance.\n\nYou can use audit logs to do the following:\n\n- View an audit log to verify whether the backup is completed successfully.\n- Configure a log-based alert to notify you of the backup's status.\n\nView an audit log\n\nYou can use the Google Cloud console, [gcloud CLI](/sdk/gcloud), or\nAPI to view an audit log to verify whether a backup is completed\nsuccessfully within a backup window. \n\nConsole\n\n1. In the Google Cloud console, select **Logging** and then select **Logs Explorer**.\n\n [Go to Logs Explorer](https://console.cloud.google.com/logs/query)\n2. To filter for audit logs for\n automated backups of Cloud SQL instances, run the following query:\n\n ```bash\n logName=\"projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/logs/cloudaudit.googleapis.com%2Fsystem_event\"\n protoPayload.methodName=\"cloudsql.instances.automatedBackup\"\n resource.type=\"cloudsql_database\"\n ```\n\n Replace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with your Google Cloud project's ID.\n\n The first expression filters for [System Event audit logs](/logging/docs/audit#system-event).\n The second expression filters for audit logs for\n automated backups. The final expression filters for audit logs\n for Cloud SQL instances.\n\n For more information about how to use the Google Cloud console to query\n for audit logs, see\n [View logs](/sql/docs/sqlserver/audit-logging#viewing_logs).\n3. View the status of a backup created during the backup window. This status is\n displayed in the `windowStatus` field. To view this field, complete the following steps:\n\n 1. Click the audit log.\n 2. Click the `metadata` field.\n\ngcloud\n\n1. To filter for audit logs for\n automated backups of Cloud SQL instances, run the following query:\n\n ```bash\n gcloud logging read \\\n \"logName=projects/\u003cvar translate=\"no\"\u003ePROJECT_NAME\u003c/var\u003e/logs/cloudaudit.googleapis.com%2Fsystem_event\n AND protoPayload.methodName=cloudsql.instances.automatedBackup AND\n resource.type=cloudsql_database\" \\ \n --project=PROJECT_NAME\n ```\n\n Replace \u003cvar translate=\"no\"\u003ePROJECT_NAME\u003c/var\u003e with your Google Cloud project's name.\n\n The first expression filters for [System Event audit logs](/logging/docs/audit#system-event).\n The second expression filters for audit logs for\n automated backups. The final expression filters for audit logs\n for Cloud SQL instances.\n\n For more information about how to use `gcloud` to query\n for audit logs, see\n [View logs](/sql/docs/sqlserver/audit-logging#viewing_logs).\n2. View the status of a backup created during the backup window. This status is\n displayed in the `windowStatus` field.\n\nAPI\n\n\nBefore using any of the request data,\nmake the following replacements:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: The ID of your Google Cloud project.\n\nFor the request JSON body, the first expression filters for [System Event audit logs](/logging/docs/audit#system-event). The second expression filters for audit logs for automated backups.\nThe final expression filters for audit logs for Cloud SQL instances.\n\nFor more information about how to use the API to query for audit\nlogs, see [View logs](/sql/docs/sqlserver/audit-logging#viewing_logs).\n\n\nHTTP method and URL:\n\n```\nPOST https://logging.googleapis.com/v2/entries:list\n```\n\n\nRequest JSON body:\n\n```\n{\n \"resourceNames\": [\n \"projects/PROJECT_ID\"\n ],\n \"pageSize\": 5,\n \"filter\": \"logName=projects/PROJECT_ID/logs/cloudaudit.googleapis.com%2Fsystem_event AND protoPayload.methodName = cloudsql.instances.automatedBackup AND resource.type=cloudsql_database\",\n \"orderBy\": \"timestamp desc\"\n} \n```\n\nTo send your request, expand one of these options:\n\ncurl (Linux, macOS, or Cloud Shell) **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](/sdk/gcloud/reference/init) or [`gcloud auth login`](/sdk/gcloud/reference/auth/login) , or by using [Cloud Shell](/shell/docs), which automatically logs you into the `gcloud` CLI . You can check the currently active account by running [`gcloud auth list`](/sdk/gcloud/reference/auth/list).\n\n\nSave the request body in a file named `request.json`,\nand execute the following command:\n\n```\ncurl -X POST \\\n -H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n -H \"Content-Type: application/json; charset=utf-8\" \\\n -d @request.json \\\n \"https://logging.googleapis.com/v2/entries:list\"\n```\n\nPowerShell (Windows) **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](/sdk/gcloud/reference/init) or [`gcloud auth login`](/sdk/gcloud/reference/auth/login) . You can check the currently active account by running [`gcloud auth list`](/sdk/gcloud/reference/auth/list).\n\n\nSave the request body in a file named `request.json`,\nand execute the following command:\n\n```\n$cred = gcloud auth print-access-token\n$headers = @{ \"Authorization\" = \"Bearer $cred\" }\n\nInvoke-WebRequest `\n -Method POST `\n -Headers $headers `\n -ContentType: \"application/json; charset=utf-8\" `\n -InFile request.json `\n -Uri \"https://logging.googleapis.com/v2/entries:list\" | Select-Object -Expand Content\n```\n\nYou should receive a JSON response similar to the following:\n\nResponse \n\n```\n{\n \"entries\": [\n {\n \"protoPayload\": {\n \"@type\": \"type.googleapis.com/google.cloud.audit.AuditLog\",\n \"status\": {\n \"message\": \"OK\"\n },\n \"authenticationInfo\": {},\n \"requestMetadata\": {\n \"requestAttributes\": {},\n \"destinationAttributes\": {}\n },\n \"serviceName\": \"cloudsql.googleapis.com\",\n \"methodName\": \"cloudsql.instances.automatedBackup\",\n \"resourceName\": \"projects/PROJECT_ID/instances/INSTANCE_NAME\",\n \"metadata\": {\n \"windowStartTime\": \"2022-12-15T13:00:00Z\",\n \"message\": \"\",\n \"windowStatus\": \"STATUS_SUCCEEDED\",\n \"@type\": \"type.googleapis.com/speckle.AutomatedBackupEventLog\",\n \"windowEndTime\": \"2022-12-15T17:00:00Z\",\n \"backupCompletionTime\": \"2022-12-15T14:11:57.347Z\",\n \"backupStartTime\": \"2022-12-15T14:11:16.631Z\"\n }\n },\n \"insertId\": \"LOG_ENTRY_UNIQUE_IDENTIFIER\",\n \"resource\": {\n \"type\": \"cloudsql_database\",\n \"labels\": {\n \"region\": \"REGION_NAME\",\n \"project_id\": \"PROJECT_ID\",\n \"database_id\": \"DATABASE_ID\"\n }\n },\n \"timestamp\": \"2022-12-15T14:11:57.391565Z\",\n \"severity\": \"INFO\",\n \"logName\": \"projects/PROJECT_ID/logs/cloudaudit.googleapis.com%2Fsystem_event\",\n \"receiveTimestamp\": \"2022-12-15T14:11:57.785814800Z\"\n },\n ],\n}\n```\n\n\u003cbr /\u003e\n\nFor more information about \u003cvar translate=\"no\"\u003eLOG_ENTRY_UNIQUE_IDENTIFIER\u003c/var\u003e\nfor the `insertId` field, see\n[LogEntry](/logging/docs/reference/v2/rest/v2/LogEntry).\n\nView the status of a backup created during the backup window. This status is\ndisplayed in the `windowStatus` field.\n\nAutomated backup statuses\n\n- `STATUS_SUCCEEDED`: The automated backup is completed successfully.\n- `STATUS_ATTEMPT_FAILED`: Cloud SQL tried to create the\n backup, but the backup either didn't start or it failed. Reasons\n for this status include:\n\n - Another backup is running on the instance.\n - The backup location is restricted by your organization policy.\n - The backup of the instance completed, but an error occurred.\n - The instance wasn't running when Cloud SQL tried to create the backup.\n- `STATUS_FAILED`: The automated backup of the instance either\n hasn't completed successfully or can't be completed within the\n backup window.\n\n For example,\n if you enabled automated backups\n and scheduled the backup window for between 1:00 am and 5:00 am, your backup\n might fail if you have many `EXPORT` operations during this time frame.\n Automated backups might also fail if there are too many conflicts with an `EXPORT` operation that runs for a long time.\n\n If Cloud SQL tries to create a backup multiple times during a\n backup window, but the backup can't be created for the reasons listed for `STATUS_ATTEMPT_FAILED`, Cloud SQL generates another audit log with\n the `windowStatus` field set to `STATUS_FAILED`.\n- `STATUS_SKIPPED`: The Cloud SQL instance [stopped running](/sql/docs/sqlserver/start-stop-restart-instance)\n since the last successful backup. Therefore, a new automated backup\n wasn't created.\n\nConfigure a log-based alert\n\nYou can [configure a log-based alert](/logging/docs/alerting/log-based-alerts) to\nnotify you of the backup's status.\n\n- If a backup has a `STATUS_SUCCEEDED` status, you can be notified for tracking purposes.\n- If a backup has the `STATUS_FAILED` or `STATUS_ATTEMPT_FAILED` status, you can be notified to take corrective action, based on the message that appears in the log entry. You can also take an [on-demand backup](/sql/docs/sqlserver/backup-recovery/backing-up) before the next scheduled backup window.\n- If a backup has a `STATUS_SKIPPED` status, you can be notified to restart the Cloud SQL instance.\n\nWhat's next\n\n- [Learn more about backing up your data](/sql/docs/sqlserver/backup-recovery/backups).\n- [Learn more about creating and managing backups](/sql/docs/sqlserver/backup-recovery/backing-up).\n- [Learn more about restoring data](/sql/docs/sqlserver/backup-recovery/restore).\n- [See how to restore your data from a backup](/sql/docs/sqlserver/backup-recovery/restoring#restorebackups).\n- [See how to perform a point-in-time recovery](/sql/docs/sqlserver/backup-recovery/restore#tips-pitr)."]]