feat: add log_all_statements opt-out to silence verbose default Postgres logging#92
Conversation
…res logging Historically, src/cluster-regional.tf prepended log_statement=all and log_min_duration_statement=0 to user-supplied cluster_parameters via concat(). The combination logs every executed statement plus its duration, which on an active cluster produces tens of millions of log lines per day and can spike CloudWatch + downstream indexed-log bills by hundreds of GB/day. Because the values were hardcoded and concatenated before the user's list, a consumer attempting to override them produced duplicate parameter names that AWS rejects at the parameter-group level — effectively no opt-out existed. This PR introduces a log_all_statements bool (default true, preserves historical behavior) that gates the hardcoded pair. Consumers who want production-sane logging set it to false and control the two parameters themselves via cluster_parameters. No behavioral change for existing callers. Fixes a real-world log-volume regression observed after deploying this component with its defaults.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughA new input variable ChangesPostgreSQL Statement Logging Toggle
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Important Do not edit the Please update the Could you fix it @ivan-pinatti? 🙏 |
|
/terratest |
Per mergify bot guidance on the PR: README.md and src/README.md are auto-generated from README.yaml + terraform-docs by the cloudposse-releaser bot after merge; human PRs should not include regen artifacts. Reverting both files to upstream main.
CI Lint was failing with conflicting constraints on cloudposse/utils:
no available releases match the given constraints
>= 1.7.1, >= 2.0.0, < 2.0.0, < 3.0.0
src/remote-state.tf (4 call sites) pinned stack-config/yaml v1.8.0,
which requires utils >= 1.7.1, < 2.0.0. CI clones aws-account-map
sibling component for ../account-map/modules/iam-roles, and
iam_roles.account_map there now uses stack-config/yaml v2.0.0, which
requires utils >= 2.0.0, < 3.0.0. The two ranges are incompatible.
Bumping all four refs to v2.0.0 aligns with the sibling component
and resolves the provider constraint. No breaking API changes
between 1.8.0 and 2.0.0 in the remote-state submodule — only the
utils version pin widens.
|
Both issues addressed — PR now has 3 commits:
Lint root cause (from the failing job's log):
Main last passed lint on 2026-03-07 with resolved constraint I verified the Happy to squash the 3 commits into one at merge time, or leave them separate for a clearer history — whichever you prefer. |
|
/terratest |
|
Thanks @ivan-pinatti for creating this pull request! A maintainer will review your changes shortly. Please don't be discouraged if it takes a while. While you wait, make sure to review our contributor guidelines. Tip Need help or want to ask for a PR review to be expedited?Join us on Slack in the |
|
@ivan-pinatti the tests still failed, please review let me know if you need help |
Terratest was failing with the same cloudposse/utils constraint conflict
that previously affected CI Lint:
no available releases match the given constraints
!= 1.4.0, >= 1.7.1, >= 2.0.0, < 2.0.0, < 3.0.0
When atmos applies aurora-postgres/basic and aurora-postgres/serverless,
src/providers.tf references ../account-map/modules/iam-roles as a local
module. That module's dependency graph therefore merges into aurora-postgres's
provider constraints. The test was vendoring account-map from the legacy
monorepo (cloudposse/terraform-aws-components//modules/account-map at
1.520.0), whose iam-roles/main.tf still uses
cloudposse/stack-config/yaml//modules/remote-state v1.5.0 — which pins
cloudposse/utils >= 1.7.1, < 2.0.0.
The previous commit (b6bfb7b) already bumped src/remote-state.tf to
stack-config v2.0.0 (utils >= 2.0.0, < 3.0.0), so the two constraints
were irreconcilable at terraform init.
Switching the vendor source to the standalone
cloudposse-terraform-components/aws-account-map repo at v1.537.2 brings
the iam-roles sub-module up to stack-config v2.0.0, aligning all
cloudposse/utils constraints in the init graph to >= 2.0.0, < 3.0.0.
Validated locally: `atmos vendor pull` + `terraform init -backend=false`
in a simulated aurora-postgres working dir resolves cloudposse/utils
v2.5.0 cleanly with no constraint conflicts.
|
Thanks for running Root cause (same class as the lint fix, different call site)When Terratest applies
My earlier commit which has no solution. Fix —
|
|
Thanks @ivan-pinatti for creating this pull request! A maintainer will review your changes shortly. Please don't be discouraged if it takes a while. While you wait, make sure to review our contributor guidelines. Tip Need help or want to ask for a PR review to be expedited?Join us on Slack in the |
|
/terratest |
|
Heads up! This pull request looks stale. It will be closed soon, if there are no new commits. ⏳ |
|
Thanks @ivan-pinatti for creating this pull request! A maintainer will review your changes shortly. Please don't be discouraged if it takes a while. While you wait, make sure to review our contributor guidelines. Tip Need help or want to ask for a PR review to be expedited?Join us on Slack in the |
|
Heads up! This pull request looks stale. It will be closed soon, if there are no new commits. ⏳ |
|
Thanks @ivan-pinatti for creating this pull request! A maintainer will review your changes shortly. Please don't be discouraged if it takes a while. While you wait, make sure to review our contributor guidelines. Tip Need help or want to ask for a PR review to be expedited?Join us on Slack in the |
|
Actionable comments posted: 0 |
|
Thanks @ivan-pinatti for creating this pull request! A maintainer will review your changes shortly. Please don't be discouraged if it takes a while. While you wait, make sure to review our contributor guidelines. Tip Need help or want to ask for a PR review to be expedited?Join us on Slack in the |
|
/terratest |
|
Thanks @ivan-pinatti for creating this pull request! A maintainer will review your changes shortly. Please don't be discouraged if it takes a while. While you wait, make sure to review our contributor guidelines. Tip Need help or want to ask for a PR review to be expedited?Join us on Slack in the |
9135a84
|
These changes were released in v2.1.0. |
Summary
log_all_statementsbool variable (defaulttrue, preserves current behavior).true,src/cluster-regional.tfcontinues to prependlog_statement=alland
log_min_duration_statement=0tocluster_parameters— no change for existing consumers.false, the hardcoded pair is skipped, so consumers can opt out and control bothparameters themselves via
cluster_parameters(e.g.log_statement=none,log_min_duration_statement=1000).Motivation
The current defaults log every executed statement plus its duration (including
sub-millisecond ones). On an active cluster this routinely produces 20M+ log
lines per day, which can spike CloudWatch Logs and any downstream log-ingest
(Datadog, Splunk, ELK) by tens to hundreds of GB per day. We observed this
first-hand: a freshly deployed Aurora Postgres cluster running Metabase
produced ~22M
postgresqllog events per day and drove a ~120 GB/dayDatadog indexed-log spike until we patched the module locally.
The values are hardcoded and
concat-ed beforevar.cluster_parameters,so a user attempting to override them ends up with duplicate parameter names
that AWS rejects at the parameter-group level. In practice there is no
opt-out today without patching the component. This PR adds that opt-out
without changing the default behavior.
How to reproduce the problem this PR fixes
Against a freshly deployed Aurora-Postgres cluster using the current
main(no PR applied):
Deploy the component with defaults — no
cluster_parametersoverride.The hardcoded concat in
src/cluster-regional.tfforceslog_statement=allandlog_min_duration_statement=0onto the clusterparameter group. Verify:
Run any real workload against the cluster for 24 hours. Count the log
events shipped to CloudWatch:
On our production Metabase cluster this returned ~22 million events/day
— every statement logged, plus a duration line for each. Ingested into
Datadog this drove a ~120 GB/day indexed-log spike.
Now try to turn it off from the catalog — e.g. append
{ name = "log_statement", value = "none", apply_method = "immediate" }to
var.cluster_parameters. Apply fails at the AWS parameter-group levelwith a duplicate-parameter-name error, because the hardcoded values are
prepended via
concat()and cannot be overridden. This is the problem:no opt-out exists today short of patching the component.
Validating the fix in this PR
Same cluster, this PR applied:
Leave
log_all_statementsunset — it defaults totrue. The parametergroup shows
log_statement=allandlog_min_duration_statement=0exactlyas before. No behavior change for existing consumers.
Set
log_all_statements = falseand supply your own values:aws rds describe-db-cluster-parameters …now shows exactly the user'svalues, no duplicates. The parameters are
SIGHUP-reloadable so thechange applies live (no reboot).
After 24 hours, rerun the CloudWatch query from step 2 of reproduction.
In our production cluster the event count dropped from ~22M/day to
~200k/day — a ~99 % reduction — driven entirely by this single
parameter-group change.
Follow-up (out of scope)
Longer term, flipping the default to
falsein a major version bump would bethe cleanest fix, since
log_statement=all+log_min_duration_statement=0is a debug-mode combination, not a safe production default. Happy to open a
separate PR for that if maintainers agree.
Summary by CodeRabbit