🛡️ Google Cloud PostgreSQL Instance cloudsql.enable_pgaudit Database Flag is not set to on🟢
- Contextual name: 🛡️ PostgreSQL Instance cloudsql.enable_pgaudit Database Flag is not set to on🟢
- ID:
/ce/ca/google/sql/postgresql-instance-cloudsql-enable-pgaudit-flag - Tags:
- Policy Type:
COMPLIANCE_POLICY - Policy Categories:
RELIABILITY
Logic
Similar Policies
- Cloud Conformity: Enable 'cloudsql.enable_pgaudit' and 'pgaudit.log' Flags for PostgreSQL Database Instances
Description
Description
Ensure the
cloudsql.enable_pgauditdatabase flag for a Cloud SQL PostgreSQL instance is set toonto allow centralized logging.Rationale
As numerous recommendations in this section involve enabling flags for logging purposes, your organization will need a way to manage these logs. You may have a solution already in place. If you do not, consider installing and enabling the open source pgAudit extension within PostgreSQL and enabling its corresponding flag
cloudsql.enable_pgaudit. This flag and extension enable database auditing in PostgreSQL through the open-source pgAudit extension. The extension provides detailed session and object logging to comply with government, financial, and ISO standards, and provides auditing capabilities to mitigate threats by monitoring security events on the instance. Enabling the flag and settings later in this recommendation sends these logs to Google Logs Explorer so that you can access them in a central location. This recommendation is applicable only to PostgreSQL database instances.... see more
Remediation
Remediation
Initialize the pgAudit flag
From Google Cloud Console
- Go to https://console.cloud.google.com/sql/instances.
- Select the instance to open its
Overviewpage.- Click
Edit.- Scroll down and expand
Flags.- To set a flag that has not been set on the instance before, click
Add item.- Enter
cloudsql.enable_pgauditfor the flag name and set the flag toon.- Click
Done.- Click
Saveto update the configuration.- Confirm your changes under
Flagson theOverviewpage.From Google Cloud CLI
Run the following command by providing
{{instance-name}}to enable thecloudsql.enable_pgauditflag.gcloud sql instances patch {{instance-name}} \
--database-flags cloudsql.enable_pgaudit=onNote:
RESTARTis required to get this configuration in effect.Creating the extension
Connect to the server running PostgreSQL or use a SQL client of your choice.
If you are using SSH, open the PostgreSQL shell by typing
psql.Run the following command as a superuser:
... see more