Skip to content

configfilesdiscovery: collect postgres env vars - #55048

Draft
martavicentenavarro wants to merge 3 commits into
mainfrom
marta.vicentenavarro/postgres-configfilesdiscovery-v3
Draft

configfilesdiscovery: collect postgres env vars#55048
martavicentenavarro wants to merge 3 commits into
mainfrom
marta.vicentenavarro/postgres-configfilesdiscovery-v3

Conversation

@martavicentenavarro

@martavicentenavarro martavicentenavarro commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds a PostgreSQL collector for Config Files Discovery that forwards a small allow-listed set of non-secret PostgreSQL environment variables:

  • PGDATA
  • POSTGRES_DB
  • POSTGRES_USER
  • POSTGRES_INITDB_WALDIR

This mirrors how env-var collection was added for Redis (#54375) and Kafka (#54217): a focused collector limited to environment variables, with the shared configfilesdiscoveryimpl.IsSecretEnvVarName filter applied as defense in depth on top of the allow-list.

Motivation

DSCVR-664

Describe how to test/QA your changes

  • Unit tests: dda inv test --targets=./comp/core/configfilesdiscovery/...
  • New Docker E2E test TestPostgresEnvVarsDiscovered in test/new-e2e/tests/discovery/configfilesdiscovery_docker_test.go, using a postgres:16 compose fixture, asserting the allowed env vars are forwarded and POSTGRES_PASSWORD (and any *PASSWORD* name) is never forwarded.

Add a PostgreSQL collector for Config Files Discovery that forwards a
small allow-listed set of non-secret environment variables (PGDATA,
POSTGRES_DB, POSTGRES_USER, POSTGRES_HOST_AUTH_METHOD,
POSTGRES_INITDB_WALDIR), matching the scope of DSCVR-664. This mirrors
how Redis (#54375) and Kafka (#54217) added env-var collection as
collector-only changes; postgresql.conf collection is a separate,
not-yet-started ticket (DSCVR-665) and is out of scope here.

Environment: Datadog workspace

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

@codex review

@github-actions github-actions Bot added the medium review PR review might take time label Aug 18, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 7c99a997d8

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@datadog-datadog-us1-prod

datadog-datadog-us1-prod Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
Patch Coverage: 84.21%
Overall Coverage: 52.47% (+0.05%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: fdf85e0 | Docs | View more details | Give us feedback!

@martavicentenavarro martavicentenavarro added changelog/no-changelog No changelog entry needed qa/done QA done before merge and regressions are covered by tests labels Aug 18, 2026 — with ddtool CLI
@dd-octo-sts

dd-octo-sts Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Files inventory check summary

File checks results against ancestor 6e12aadd:

Results for datadog-agent_7.84.0~devel.git.268.fdf85e0.pipeline.131672124-1_amd64.deb:

No change detected

Results for datadog-iot-agent_7.84.0~devel.git.268.fdf85e0.pipeline.131672124-1_amd64.deb:

No change detected

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Aug 18, 2026

Copy link
Copy Markdown

Regression Detector

Regression Detector Results

Metrics dashboard
Target profiles
Job ID: 32f16421-67fa-4ded-b159-2c084d0052d5

Baseline: 6e12aad
Comparison: fdf85e0
Diff

Optimization Goals: ✅ No significant changes detected

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI trials links
quality_gate_metrics_logs memory utilization +0.40 [+0.16, +0.65] 1 Logs bounds checks dashboard
quality_gate_private_action_runner memory utilization +0.19 [+0.07, +0.31] 1 Logs bounds checks dashboard
quality_gate_idle memory utilization +0.14 [+0.02, +0.26] 1 Logs bounds checks dashboard
quality_gate_security_idle memory utilization -0.14 [-0.25, -0.03] 1 Logs bounds checks dashboard
quality_gate_idle_all_features memory utilization -0.15 [-0.19, -0.11] 1 Logs bounds checks dashboard
quality_gate_security_mean_fs_load memory utilization -0.27 [-0.34, -0.19] 1 Logs bounds checks dashboard
quality_gate_security_no_fs_load memory utilization -0.45 [-0.59, -0.30] 1 Logs bounds checks dashboard
quality_gate_logs % cpu utilization -1.24 [-2.10, -0.38] 1 Logs bounds checks dashboard

Bounds Checks: ✅ Passed

perf experiment bounds_check_name replicates_passed observed_value links
quality_gate_idle intake_connections 10/10 4 = 4 bounds checks dashboard
quality_gate_idle memory_usage 10/10 173.00MiB ≤ 178MiB bounds checks dashboard
quality_gate_idle total_bytes_received 10/10 745.06KiB ≤ 819.20KiB bounds checks dashboard
quality_gate_idle_all_features intake_connections 10/10 4 = 4 bounds checks dashboard
quality_gate_idle_all_features memory_usage 10/10 510.72MiB ≤ 538MiB bounds checks dashboard
quality_gate_idle_all_features total_bytes_received 10/10 1.13MiB ≤ 1.25MiB bounds checks dashboard
quality_gate_logs intake_connections 10/10 17 ≤ 40 bounds checks dashboard
quality_gate_logs memory_usage 10/10 204.22MiB ≤ 229MiB bounds checks dashboard
quality_gate_logs missed_bytes 10/10 0B = 0B bounds checks dashboard
quality_gate_logs total_bytes_received 10/10 264.18MiB ≤ 292MiB bounds checks dashboard
quality_gate_metrics_logs cpu_usage 10/10 355.85 ≤ 2000 bounds checks dashboard
quality_gate_metrics_logs intake_connections 10/10 19 ≤ 40 bounds checks dashboard
quality_gate_metrics_logs memory_usage 10/10 405.26MiB ≤ 439MiB bounds checks dashboard
quality_gate_metrics_logs missed_bytes 10/10 0B = 0B bounds checks dashboard
quality_gate_metrics_logs total_bytes_received 10/10 0.94GiB ≤ 1.04GiB bounds checks dashboard
quality_gate_private_action_runner memory_usage 10/10 71.40MiB ≤ 76MiB bounds checks dashboard
quality_gate_security_idle cpu_usage 10/10 26.86 ≤ 100 bounds checks dashboard
quality_gate_security_idle memory_usage 10/10 331.94MiB ≤ 335MiB bounds checks dashboard
quality_gate_security_mean_fs_load cpu_usage 10/10 61.37 ≤ 200 bounds checks dashboard
quality_gate_security_mean_fs_load memory_usage 10/10 303.97MiB ≤ 314MiB bounds checks dashboard
quality_gate_security_no_fs_load cpu_usage 10/10 20.37 ≤ 100 bounds checks dashboard
quality_gate_security_no_fs_load memory_usage 10/10 312.05MiB ≤ 343MiB bounds checks dashboard

Explanation

Confidence level: 90.00%
Effect size tolerance: |Δ mean %| ≥ 5.00%

Performance changes are noted in the perf column of each table:

  • ✅ = significantly better comparison variant performance
  • ❌ = significantly worse comparison variant performance
  • ➖ = no significant change in performance

A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".

For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.

  3. Its configuration does not mark it "erratic".

CI Pass/Fail Decision

Passed. All Quality Gates passed.

  • quality_gate_security_mean_fs_load, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_mean_fs_load, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_private_action_runner, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check missed_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check missed_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_security_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_idle, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_no_fs_load, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_no_fs_load, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.

@dd-octo-sts

dd-octo-sts Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Static quality checks

✅ Please find below the results from static quality gates
Comparison made with ancestor 6e12aad
📊 Static Quality Gates Dashboard
🔗 SQG Job

Successful checks

Info

Quality gate Change Size (prev → curr → max)
agent_deb_amd64 +4.0 KiB (0.00% increase, -0.09% of buffer) 760.252 → 760.256 → 764.500
agent_msi +4.5 KiB (0.00% increase, -0.03% of buffer) 643.969 → 643.973 → 660.960
agent_rpm_amd64 +4.0 KiB (0.00% increase, -0.09% of buffer) 760.236 → 760.240 → 764.470
agent_rpm_arm64 +4.0 KiB (0.00% increase, -0.68% of buffer) 735.968 → 735.972 → 736.540
agent_rpm_arm64_fips +4.0 KiB (0.00% increase, -0.26% of buffer) 692.210 → 692.214 → 693.690
agent_suse_amd64 +4.0 KiB (0.00% increase, -0.09% of buffer) 760.236 → 760.240 → 764.470
agent_suse_arm64 +4.0 KiB (0.00% increase, -0.68% of buffer) 735.968 → 735.972 → 736.540
agent_suse_arm64_fips +4.0 KiB (0.00% increase, -0.26% of buffer) 692.210 → 692.214 → 693.690
docker_agent_amd64 +4.0 KiB (0.00% increase, -0.34% of buffer) 818.895 → 818.899 → 820.040
docker_agent_arm64 +4.0 KiB (0.00% increase, -0.38% of buffer) 819.707 → 819.711 → 820.740
docker_agent_jmx_amd64 +4.0 KiB (0.00% increase, -0.39% of buffer) 1009.793 → 1009.797 → 1010.800
docker_agent_jmx_arm64 +4.0 KiB (0.00% increase, -0.34% of buffer) 999.257 → 999.261 → 1000.420
21 successful checks with minimal change (< 2 KiB)
Quality gate Current Size
agent_deb_amd64_fips 713.133 MiB
agent_heroku_amd64 312.490 MiB
agent_rpm_amd64_fips 713.117 MiB
agent_suse_amd64_fips 713.117 MiB
docker_cluster_agent_amd64 210.451 MiB
docker_cluster_agent_arm64 223.456 MiB
docker_cws_instrumentation_amd64 7.439 MiB
docker_cws_instrumentation_arm64 6.877 MiB
docker_dogstatsd_amd64 39.455 MiB
docker_dogstatsd_arm64 37.560 MiB
docker_host_profiler_amd64 305.774 MiB
docker_host_profiler_arm64 317.038 MiB
dogstatsd_deb_amd64 30.200 MiB
dogstatsd_deb_arm64 28.224 MiB
dogstatsd_rpm_amd64 30.200 MiB
dogstatsd_suse_amd64 30.200 MiB
iot_agent_deb_amd64 46.452 MiB
iot_agent_deb_arm64 43.104 MiB
iot_agent_deb_armhf 43.887 MiB
iot_agent_rpm_amd64 46.452 MiB
iot_agent_suse_amd64 46.451 MiB

@martavicentenavarro

Copy link
Copy Markdown
Contributor Author

@codex

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7c99a997d8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

"PGDATA": {},
"POSTGRES_DB": {},
"POSTGRES_USER": {},
"POSTGRES_HOST_AUTH_METHOD": {},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Do not forward credentials embedded in the auth method

When POSTGRES_HOST_AUTH_METHOD contains PostgreSQL HBA options—for example, ldap ... ldapbindpasswd=secret or radius ... radiussecret=secret—the official Postgres image appends the entire value to pg_hba.conf. Allowlisting this variable forwards that entire credential-bearing value; IsSecretEnvVarName cannot protect it because it examines only the variable name. Omit this variable or sanitize it to a known-safe authentication method before collection.

Useful? React with 👍 / 👎.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds PostgreSQL environment-variable collection to the Config Files Discovery (configfilesdiscovery) component, mirroring the existing Redis/Kafka env-var collectors while keeping collection restricted to an allow-list and applying the shared secret-name filter for defense in depth.

Changes:

  • Introduces a new Postgres configfilesdiscovery collector that forwards a small allow-listed set of non-secret env vars.
  • Registers the Postgres collector in the configfilesdiscovery Fx wiring so it can be scheduled via Autodiscovery (postgres integration).
  • Adds unit tests for the collector and extends the Docker E2E suite with a Postgres compose fixture + env-var discovery assertions.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/new-e2e/tests/discovery/testdata/compose/docker-compose.configfilesdiscovery-postgres.yaml Adds a Postgres compose fixture used by the Docker E2E discovery suite.
test/new-e2e/tests/discovery/configfilesdiscovery_docker_test.go Adds an E2E test that validates Postgres env-var discovery payloads reach fakeintake.
comp/core/configfilesdiscovery/impl/collectors/postgres.go Implements the Postgres env-var collector with allow/deny lists and secret-name filtering.
comp/core/configfilesdiscovery/impl/collectors/postgres_test.go Adds unit tests for allow/deny logic and collector behavior.
comp/core/configfilesdiscovery/impl/collectors/BUILD.bazel Wires the new collector + tests into Bazel targets.
comp/core/configfilesdiscovery/fx/fx.go Registers the Postgres collector in the component’s collector map.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +7 to +10
environment:
POSTGRES_DB: configfilesdiscovery
POSTGRES_USER: configfilesdiscovery
POSTGRES_PASSWORD: must-not-be-forwarded
Comment on lines +383 to +385
assert.Equal(c, postgresDBName, envVars["POSTGRES_DB"])
assert.Equal(c, postgresUser, envVars["POSTGRES_USER"])
assert.NotContains(c, envVars, "POSTGRES_PASSWORD")
Comment on lines +51 to +53
// NewPostgres returns a collector that reads selected, non-secret PostgreSQL
// environment variables. It does not read postgresql.conf; config-file
// collection is a separate collector.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/no-changelog No changelog entry needed internal Identify a non-fork PR medium review PR review might take time qa/done QA done before merge and regressions are covered by tests team/agent-build team/agent-discovery

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants