> 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-13.md).

# GCP PostgreSQL instance database flag log\_duration is not set to on misconfiguration detected in cod

## Rule Details

|                        |                                      |
| ---------------------- | ------------------------------------ |
| Cortex AppSec Rule ID  | APPSEC2\_GCP\_13                     |
| Category - Subcategory | Logging - Disabled or missing        |
| Provider               | GCP                                  |
| Severity               | LOW                                  |
| Framework              | Terraform, Terraform Plan            |
| Mapped CSPM/KSPM Rule  | cfcc1ccb-7333-4667-b84c-48949d18264a |

## Impact

This rule verifies if the 'log\_duration' flag is set to 'on' for a PostgreSQL database in Google Cloud Platform (GCP). The 'log\_duration' flag, when turned on, logs the duration of each completed SQL command that was run on the PostgreSQL instance.

If this configuration is not enabled, it could lead to less visibility in monitoring and diagnosing database performance issues. This lack of insight can introduce difficulties when trying to troubleshoot or optimize performance because durations of SQL commands are crucial to understanding where potential slowdowns or bottlenecks may lie. So, leaving 'log\_duration' off can limit the ability to effectively manage the database.

## How to Fix

*Resource:* google\_sql\_database\_instance

* *Arguments:* settings.database\_flags

To fix this issue, you need to ensure that the 'log\_duration' flag in the PostgreSQL database is set to 'on'.

## In the above code, 'log\_duration' is set to 'on' for the PostgreSQL instance. This means that each statement's duration will be logged, enhancing the visibility and traceability of operations conducted on your database, further strengthening its security against any potential unauthorized access or actions. \[source,go]

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

## settings { database\_flags { name = "log\_duration" value = "on" } } }


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
