For the complete documentation index, see llms.txt. This page is also available as Markdown.
Cortex CloudApplication Security

GCP PostgreSQL instance database flag log_parser_stats is not set to off misconfiguration detected i

Rule Details

Cortex AppSec Rule ID

APPSEC2_GCP_15

Category - Subcategory

Logging - Disabled or missing

Provider

GCP

Severity

LOW

Framework

Terraform, Terraform Plan

Mapped CSPM/KSPM Rule

5072e3b8-0767-433b-9b06-d2003ba13650

Impact

This rule is checking to verify if the 'log_parser_stats' flag in the PostgreSQL database is set to 'off'. This flag, when turned on, logs statistical information about query parsing and rewriting. While this might be useful for debugging, it can generate a vast amount of log data significantly consuming disk space, and may potentially lead to performance degradation. Therefore, for optimal performance and saving resources, it is generally recommended to set the 'log_parser_stats' flag to 'off' in a production environment.

How to Fix

Resource: google_sql_database_instance

  • Arguments: settings.database_flags

To fix the issue, you should ensure that the 'log_parser_stats' flag for your PostgreSQL database is set to 'off'. Here is an example of how to do it in your Terraform file:

The above code is secure because the 'log_parser_stats' flag is explicitly set to 'off'. The 'log_parser_stats' flag in PostgreSQL enables detailed statistics for the parser stage of query execution, including the number of created and used tokens and the number of created and used parse nodes. Logging these statistics can have a significant performance impact. So, having this flag off helps in reducing the overhead of unnecessary logging, decreasing the chance of slowed performance of your PostgreSQL database. [source,go]

resource "google_sql_database_instance" "default" { name = "database" region = "us-central1"

database_version = "POSTGRES_11"

settings { database_flags { name = "log_parser_stats" value = "off" } } }

Last updated

Was this helpful?