Skip to main content

More Info:

Ensure that the log_parser_stats database flag for a Cloud SQL PostgreSQL instance is set to off.

Risk Level

Low

Address

Reliability, Security

Compliance Standards

CBP

Triage and Remediation

Remediation

Using Console

To remediate the PostgreSQL Log Parser Stats Flag Should Be Off misconfiguration in GCP using the GCP console, follow these steps:
  1. Open the GCP Console and navigate to the Cloud SQL instances page.
  2. Click on the name of the instance that has the PostgreSQL Log Parser Stats Flag Should Be Off misconfiguration.
  3. In the left-hand menu, click on the Configuration tab.
  4. Scroll down to the Flags section and click on Edit.
  5. In the Flags editor, search for the log_parser_stats flag.
  6. If the log_parser_stats flag is set to ON, toggle it to OFF.
  7. Click Save to apply the changes.
Once the changes are saved, the PostgreSQL Log Parser Stats Flag will be turned off and the misconfiguration will be remediated.

To remediate the PostgreSQL Log Parser Stats Flag Should Be Off misconfiguration in GCP using GCP CLI, you can follow these steps:
  1. Open the Cloud Shell in the GCP console.
  2. Run the following command to list all the Cloud SQL instances in your project:
  3. Identify the instance that has the PostgreSQL Log Parser Stats Flag Should Be Off misconfiguration.
  4. Run the following command to update the instance settings:
    Replace [INSTANCE_NAME] with the name of the instance that you identified in step 3.
  5. Verify that the log_parser_stats flag is set to off by running the following command:
    Replace [INSTANCE_NAME] with the name of the instance that you identified in step 3. Look for the following line in the output:
    If you see this line, the misconfiguration has been remediated successfully.
That’s it! You have successfully remediated the PostgreSQL Log Parser Stats Flag Should Be Off misconfiguration for the specified GCP instance using GCP CLI.
To remediate the PostgreSQL Log Parser Stats Flag Should Be Off misconfiguration in GCP using python, follow these steps:
  1. Install the google-cloud-secret-manager and google-cloud-logging python packages using pip.
  2. Import the necessary libraries.
  3. Retrieve the value of the POSTGRES_STATS_FLAG secret from Google Secret Manager.
    Replace <PROJECT_ID>, <SECRET_NAME>, and <SECRET_VERSION> with the appropriate values.
  4. Update the log sink for PostgreSQL to disable the log parser stats flag.
    Replace <PROJECT_ID>, <INSTANCE_ID>, and <ZONE> with the appropriate values.
  5. Verify that the log sink has been updated successfully.
    Replace <SINK_NAME> and <PROJECT_ID> with the appropriate values.
That’s it! The PostgreSQL Log Parser Stats Flag Should Be Off misconfiguration has been remediated for GCP using python.