Triage and Remediation
Remediation
Using Console
Using Console
To remediate the PostgreSQL Log Planner Stats Flag misconfiguration for GCP using GCP console, you can follow the below steps:
- Login to your GCP console.
- Navigate to the Cloud SQL instances page.
- Select the instance that you want to remediate.
- Click on the Edit button at the top of the page.
- Scroll down to the Flags section and click on the Add flag button.
- In the Flag name field, enter “log_planner_stats” (without quotes).
- In the Flag value field, enter “off” (without quotes).
- Click on the Save button at the bottom of the page to save the changes.
Using CLI
Using CLI
To remediate the PostgreSQL Log Planner Stats Flag misconfiguration in GCP using GCP CLI, you can follow the below steps:
- Open the Cloud Shell in your GCP console.
-
Run the following command to list all the instances in your project:
gcloud sql instances list
- Identify the instance for which you want to remediate the misconfiguration and note down its instance name.
-
Run the following command to get the current value of the PostgreSQL log_planner_stats flag:
gcloud sql instances describe [INSTANCE_NAME] --format="value(settings.postgresql.log_planner_stats)"
Replace [INSTANCE_NAME] with the name of your instance. -
If the output of the above command is “on”, then run the following command to turn off the PostgreSQL log_planner_stats flag:
gcloud sql instances patch [INSTANCE_NAME] --database-flags log_planner_stats=off
Replace [INSTANCE_NAME] with the name of your instance. -
Verify the PostgreSQL log_planner_stats flag has been turned off by running the following command:
gcloud sql instances describe [INSTANCE_NAME] --format="value(settings.postgresql.log_planner_stats)"
Replace [INSTANCE_NAME] with the name of your instance. - Ensure that the PostgreSQL log_planner_stats flag is turned off for all the instances in your project to avoid any further misconfiguration.
Using Python
Using Python
To remediate the “PostgreSQL Log Planner Stats Flag Should Be Off” misconfiguration for GCP using Python, you can follow the below steps:Step 1: Import the required librariesStep 2: Set up the authentication credentialsStep 3: Create a BigQuery client objectStep 4: Run the following query to check the current value of the Step 5: If the value of Note: This query will update the configuration file for PostgreSQL, but it will not take effect until the database is restarted.Step 6: Verify that the
log_planner_stats
flag:log_planner_stats
is on
, run the following query to turn it off:log_planner_stats
flag is now set to off
by running the query in Step 4 again.By following the above steps, you can remediate the “PostgreSQL Log Planner Stats Flag Should Be Off” misconfiguration for GCP using Python.