Skip to content

[BUG] Agent tries to query column nspname on pg_index #41130

@sardaukar

Description

@sardaukar

Agent Environment

We have the agent (v7.70.2) deployed on our Render production environment, and we have a persistent error message on our logs:

2025-09-22 14:50:23 UTC | CORE | INFO | (pkg/collector/worker/check_logger.go:40 in CheckStarted) | check:postgres | Running check...
2025-09-22 14:50:23 UTC | CORE | ERROR | (pkg/collector/python/datadog_agent.go:143 in LogMessage) | postgres:f26eb3c74874f76b | (postgres.py:273) | Unhandled exception while using database connection <REDACTED_DB_NAME>
Traceback (most recent call last):
  File "/opt/datadog-agent/embedded/lib/python3.12/site-packages/datadog_checks/postgres/postgres.py", line 258, in db
    yield self._db
  File "/opt/datadog-agent/embedded/lib/python3.12/site-packages/datadog_checks/postgres/postgres.py", line 241, in execute_query_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".
2025-09-22 14:50:23 UTC | CORE | ERROR | (pkg/collector/python/datadog_agent.go:143 in LogMessage) | - | (core.py:94) | Error querying pg_index: 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".
2025-09-22 14:50:23 UTC | CORE | INFO | (pkg/collector/worker/check_logger.go:59 in CheckFinished) | check:postgres | Done running check

Which makes sense, since pg_index doesn't have an "nspname" column 🤷‍♂️

agent version output:

Agent 7.70.2 - Commit: 83bbd72567 - Serialization version: v5.0.161 - Go version: go1.24.6
our config:
init_config:
instances:
  - dbm: true
    host: REDACTED-a
    port: 5432
    username: datadog
    password: REDACTED
    dbname: REDACTED
    ssl: prefer
    dbstrict: true
    relations:
      - relation_regex: .*
        schemas:
          - public
        relkind:
          - r
          - i
    collect_schemas:
      enabled: true
    query_samples:
      explain_parameterized_queries: true
    tags:
      - 'env:prod'
      - 'service:REDACTED'
  - dbm: true
    host: REDACTED-b
    port: 5432
    username: datadog
    password: REDACTED
    dbname: REDACTED
    ssl: prefer
    dbstrict: true
    query_samples:
      explain_parameterized_queries: true
    tags:
      - 'env:prod'
      - 'service:REDACTED_replica'
  - dbm: true
    host: REDACTED-c
    port: 5432
    username: datadog
    password: REDACTED
    dbname: REDACTED
    ssl: prefer
    dbstrict: true
    query_samples:
      explain_parameterized_queries: true
    tags:
      - 'env:prod'
      - 'service:REDACTED_replica_two'
  - dbm: true
    host: REDACTED
    port: 5432
    username: datadog
    password: REDACTED
    dbname: REDACTED
    ssl: prefer
    dbstrict: true
    relations:
      - relation_regex: .*
        schemas:
          - public
        relkind:
          - r
          - i
    collect_schemas:
      enabled: true
    query_samples:
      explain_parameterized_queries: true
    tags:
      - 'env:prod'
      - 'service:REDACTED_oban'

We even changed it to have just

 relkind:
   - r

In an attempt to remove indices from being monitored, but we still see the same log message :(

Describe what happened:

  • Persistent error message in the logs

Describe what you expected:

  • No error message

Steps to reproduce the issue:

  • Run datadog-agent on Render

Additional environment details (Operating System, Cloud provider, etc):

Render DB instances, using a variation of Render's own DD agent template. Three of the four instances are v15, one of them is v17 - but the error message seems to be from a DB running v15. Regardless, pg_index didn't have nspname in v15 either, so I don't think it's a v17 issue that I know it's not on your list of supported versions.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions