> For the complete documentation index, see [llms.txt](https://cortex-docs.paloaltonetworks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cortex-docs.paloaltonetworks.com/appsec-rules/iac-security/logging/appsec2-gcp-17.md).

# GCP PostgreSQL instance database flag log\_statement\_stats is not set to off misconfiguration detecte

## Rule Details

|                        |                                      |
| ---------------------- | ------------------------------------ |
| Cortex AppSec Rule ID  | APPSEC2\_GCP\_17                     |
| Category - Subcategory | Logging - Disabled or missing        |
| Provider               | GCP                                  |
| Severity               | LOW                                  |
| Framework              | Terraform, Terraform Plan            |
| Mapped CSPM/KSPM Rule  | ef360d7f-cd86-4c78-89f1-53c296853e2d |

## Impact

This rule is examining whether the 'log\_statement\_stats' flag for PostgreSQL databases is set to 'off'. The 'log\_statement\_stats' setting controls whether detailed statistics on each statement that is executed are included in the server's logs. If it is set to 'on', this would generate a lot of log output, especially for systems executing complex operations, which can easily fill up the storage media, affect database performance, and make the logs difficult to read. Moreover, the information collected by the 'log\_statement\_stats' could potentially contain sensitive data, thus posing a data exposure risk. Hence, it's recommended to set it to 'off' by default and only enable it temporarily when needed for debugging.

## How to Fix

*Resource:* google\_sql\_database\_instance

* *Arguments:* settings.database\_flags

To fix this issue, you need to ensure that the PostgreSQL database flag 'log\_statement\_stats' is set to 'off'. This can be achieved by including the flag in the settings of the managed PostgreSQL database instance like this:

## The provided code is secure because it turns off the PostgreSQL database flag 'log\_statement\_stats'. This flag, when turned on, causes the system to compute and report the detailed statement-level statistics about the workload of the PostgreSQL server. Turning off this flag is a good practice for the production database because intensive statistics gathering will likely have substantial overhead on the server's performance. Thus, setting 'log\_statement\_stats' to 'off' will enhance the performance of your PostgreSQL database. \[source,go]

resource "google\_sql\_database\_instance" "default" { name = "default" database\_version = "POSTGRES\_9\_6" region = "us-central1"

## settings { database\_flags { name = "log\_statement\_stats" value = "off" } } }


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://cortex-docs.paloaltonetworks.com/appsec-rules/iac-security/logging/appsec2-gcp-17.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
