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