Skip to content
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

Postgres autodiscovery settings do not exclude databases for query samples #18783

Open
smcgivern opened this issue Oct 7, 2024 · 1 comment

Comments

@smcgivern
Copy link

smcgivern commented Oct 7, 2024

We are using AlloyDB, which has a database like the auto-excluded cloudsqladmin, but called alloydbadmin (there's also an alloydbmetadata DB).

We have this config:

collect_bloat_metrics: true
database_autodiscovery:
  enabled: true
  exclude:
  - alloydbadmin
  - alloydbmetadata
  include:
  - REDACTED # But they are literal DB names, no regex metacharacters
dbm: true
empty_default_hostname: true
host: REDACTED
max_relations: 1000
password: REDACTED
port: 5432
query_samples:
  explain_parameterized_queries: true
relations:
- relation_regex: .*
  schemas:
  - public
reported_hostname: REDACTED
ssl: require
tags:
- REDACTED
username: datadog

(I don't think I should need the exclude at all, but I added it in an attempt to debug this.)

When we run checks, the datadog user attempts to connect to the alloydbadmin and alloydbmetadata DBs and fails, as it doesn't have access. Are we trying to exclude this in the wrong way?

Logs look like this:

2024-10-07 13:24:14 UTC | CORE | DEBUG | (pkg/collector/python/datadog_agent.go:133 in LogMessage) | postgres:672cac915837c236 | (statement_samples.py:540) | using cached explain_setup_state for DB 'alloydbadmin': DBExplainError.failed_function
2024-10-07 13:46:10 UTC | CORE | WARN | (pkg/collector/python/datadog_agent.go:129 in LogMessage) | postgres:da54d250a2fa72fe | (postgres.py:982) | Unable to collect execution plans in dbname=alloydbadmin. Check that the function datadog.explain_statement exists in the database. See https://docs.datadoghq.com/database_monitoring/setup_postgres/troubleshooting#undefined-explain-function for more details: connection to server at "REDACTED", port 5432 failed: FATAL:  pg_hba.conf rejects connection for host "REDACTED", user "datadog", database "alloydbadmin", SSL encryption

I see there are also exclusions for schema collection (#18145), but nothing for statement collection.

It might be nice to have one config setting that means the agent will never attempt to connect to or report anything about a particular DB, rather than in several places?

@smcgivern
Copy link
Author

Support confirmed that we also need to set ignore_databases: https://github.com/DataDog/integrations-core/blob/master/postgres/datadog_checks/postgres/data/conf.yaml.example#L74-L84

I do think this is confusing, especially the difference in terminology (exclude vs ignore), but I appreciate that will be hard to change in a non-breaking way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant