Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[SDBM-2099] Fixes an issue querying table and index metrics on the public schema #21686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
eric-weaver merged 2 commits into master from eric.weaver/SDBM-2099
Oct 16, 2025

Conversation

@eric-weaver
Copy link
Contributor

@eric-weaver eric-weaver commented Oct 16, 2025
edited by atlassian bot
Loading

What does this PR do?

This PR fixes an issue reported where the Postgres integration is querying non-existent columns when collecting table or index metrics on the public schema.

This was reproduced locally with the following config snippet

 relations:
 - relation_regex: .*
 schemas:
 - public
 relkind:
 - r
 - i

Previously this configuration would lead to the following exception while collecting relation metrics

(postgres.py:279) | Unhandled exception while using database connection postmaster
Traceback (most recent call last):
 File "/opt/datadog-agent/embedded/lib/python3.12/site-packages/datadog_checks/postgres/postgres.py", line 264, in db
 yield self._db
 File "/opt/datadog-agent/embedded/lib/python3.12/site-packages/datadog_checks/postgres/postgres.py", line 247, in execute_quer
y_raw
 cursor.execute(query)
 File "/opt/datadog-agent/embedded/lib/python3.12/site-packages/datadog_checks/postgres/cursor.py", line 28, in execute
 return super().execute(query, params, binary=binary, prepare=prepare)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/opt/datadog-agent/embedded/lib/python3.12/site-packages/psycopg/cursor.py", line 97, in execute
 raise ex.with_traceback(None)
psycopg.errors.UndefinedColumn: column "nspname" does not exist
LINE 30: ) s WHERE (( 1=1 AND nspname = ANY(array['public']::text[]) ...
 ^
HINT: Perhaps you meant to reference the column "s.relname".`

This occurs because we hardcode adding nspname into our relations filter but our index and table queries had aliased the column name so it didn't exist. Now we're aligning the column aliases to this nspname constant so that our filtering works properly.

No impact on reporting metrics/tags on touched queries should be expected from the column alias changes

Motivation

Fixes issue and SDBM-2099

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Add the qa/skip-qa label if the PR doesn't need to be tested during QA.
  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged

chatgpt-codex-connector[bot] reacted with thumbs up emoji
Copy link

codecov bot commented Oct 16, 2025
edited
Loading

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.29%. Comparing base (336c4cf) to head (6c7fcbf).
⚠️ Report is 7 commits behind head on master.

Additional details and impacted files
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

datadog-datadog-prod-us1 bot commented Oct 16, 2025
edited by datadog-official bot
Loading

⚠️ Tests

⚠️ Warnings

🧪 1 Test failed

test_common_metrics[False] from test_pg_integration.py (Datadog)
Some metrics are collected but not asserted:
Asserted Metrics:
	- dd.postgres.operation.time
	- postgresql.activity.wait_event
	- postgresql.archiver.archived_count
	- postgresql.archiver.failed_count
	- postgresql.before_xid_wraparound
	- postgresql.bgwriter.buffers_alloc
	- postgresql.bgwriter.buffers_backend
	- postgresql.bgwriter.buffers_backend_fsync
...

i️ Info

❄️ No new flaky tests detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 6c7fcbf | Docs | Was this helpful? Give us feedback!

@eric-weaver eric-weaver added this pull request to the merge queue Oct 16, 2025
Merged via the queue into master with commit ec2339a Oct 16, 2025
98 of 101 checks passed
@eric-weaver eric-weaver deleted the eric.weaver/SDBM-2099 branch October 16, 2025 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@sethsamuel sethsamuel sethsamuel approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[BUG] Agent tries to query column nspname on pg_index

AltStyle によって変換されたページ (->オリジナル) /