A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cloud.google.com/sql/docs/postgres/backup-recovery/view-audit-logs-for-automated-backups below:

View audit logs for automated backups | Cloud SQL for PostgreSQL

This page describes how to view an audit log for an automated backup of your Cloud SQL instance.

You can use the Google Cloud console, gcloud CLI, or API to view an audit log to verify whether a backup is completed successfully within a backup window.

Console
  1. In the Google Cloud console, select Logging and then select Logs Explorer.

    Go to Logs Explorer

  2. To filter for audit logs for automated backups of Cloud SQL instances, run the following query:

    logName="projects/PROJECT_ID/logs/cloudaudit.googleapis.com%2Fsystem_event"
    protoPayload.methodName="cloudsql.instances.automatedBackup"
    resource.type="cloudsql_database"

    Replace PROJECT_ID with your Google Cloud project's ID.

    The first expression filters for System Event audit logs. The second expression filters for audit logs for automated backups. The final expression filters for audit logs for Cloud SQL instances.

    For more information about how to use the Google Cloud console to query for audit logs, see View logs.

  3. View the status of a backup created during the backup window. This status is displayed in the windowStatus field. To view this field, complete the following steps:

    1. Click the audit log.
    2. Click the metadata field.
gcloud
  1. To filter for audit logs for automated backups of Cloud SQL instances, run the following query:

    gcloud logging read \
    "logName=projects/PROJECT_NAME/logs/cloudaudit.googleapis.com%2Fsystem_event
    AND protoPayload.methodName=cloudsql.instances.automatedBackup AND
    resource.type=cloudsql_database" \ 
        --project=PROJECT_NAME

    Replace PROJECT_NAME with your Google Cloud project's name.

    The first expression filters for System Event audit logs. The second expression filters for audit logs for automated backups. The final expression filters for audit logs for Cloud SQL instances.

    For more information about how to use gcloud to query for audit logs, see View logs.

  2. View the status of a backup created during the backup window. This status is displayed in the windowStatus field.

API

Before using any of the request data, make the following replacements:

For the request JSON body, the first expression filters for System Event audit logs. The second expression filters for audit logs for automated backups. The final expression filters for audit logs for Cloud SQL instances.

For more information about how to use the API to query for audit logs, see View logs.

HTTP method and URL:

POST https://logging.googleapis.com/v2/entries:list

Request JSON body:

{
     "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"
} 

To send your request, expand one of these options:

curl (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 or gcloud auth login , or by using Cloud Shell, which automatically logs you into the gcloud CLI . You can check the currently active account by running gcloud auth list.

Save the request body in a file named request.json, and execute the following command:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://logging.googleapis.com/v2/entries:list"
PowerShell (Windows) Note: The following command assumes that you have logged in to the gcloud CLI with your user account by running gcloud init or gcloud auth login . You can check the currently active account by running gcloud auth list.

Save the request body in a file named request.json, and execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `


-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://logging.googleapis.com/v2/entries:list" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

Response
{
  "entries": [
    {
      "protoPayload": {
        "@type": "type.googleapis.com/google.cloud.audit.AuditLog",
        "status": {
          "message": "OK"
        },
        "authenticationInfo": {},
        "requestMetadata": {
          "requestAttributes": {},
          "destinationAttributes": {}
        },
        "serviceName": "cloudsql.googleapis.com",
        "methodName": "cloudsql.instances.automatedBackup",
        "resourceName": "projects/PROJECT_ID/instances/INSTANCE_NAME",
        "metadata": {
          "windowStartTime": "2022-12-15T13:00:00Z",
          "message": "",
          "windowStatus": "STATUS_SUCCEEDED",
          "@type": "type.googleapis.com/speckle.AutomatedBackupEventLog",
          "windowEndTime": "2022-12-15T17:00:00Z",
          "backupCompletionTime": "2022-12-15T14:11:57.347Z",
          "backupStartTime": "2022-12-15T14:11:16.631Z"
        }
      },
      "insertId": "LOG_ENTRY_UNIQUE_IDENTIFIER",
      "resource": {
        "type": "cloudsql_database",
        "labels": {
          "region": "REGION_NAME",
          "project_id": "PROJECT_ID",
          "database_id": "DATABASE_ID"
        }
      },
      "timestamp": "2022-12-15T14:11:57.391565Z",
      "severity": "INFO",
      "logName": "projects/PROJECT_ID/logs/cloudaudit.googleapis.com%2Fsystem_event",
      "receiveTimestamp": "2022-12-15T14:11:57.785814800Z"
    },
 ],
}

For more information about LOG_ENTRY_UNIQUE_IDENTIFIER for the insertId field, see LogEntry.

View the status of a backup created during the backup window. This status is displayed in the windowStatus field.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4