追加のテーブルをクエリする必要があるデータ収集またはカスタムメトリクスでは、それらのテーブルの SELECT 権限を datadog ユーザーに付与する必要がある場合があります。例: grant SELECT on <TABLE_NAME> to datadog;。詳細は、PostgreSQL カスタムメトリクス収集を参照してください。
Store your password using secret management software such as Vault. You can then reference this password as ENC[<SECRET_NAME>] in your Agent configuration files: for example, ENC[datadog_user_database_password]. See Secrets Management for more information.
The examples on this page use datadog_user_database_password to refer to the name of the secret where your password is stored. It is possible to reference your password in plain text, but this is not recommended.
postgres.d/conf.yaml ファイルを編集して、host / port を指定し、監視するマスターを設定します。使用可能なすべてのコンフィギュレーションオプションについては、サンプル postgres.d/conf.yaml を参照してください。
init_config:instances:- dbm:truehost:'<AWS_INSTANCE_ENDPOINT>'port:5432username:datadogpassword:'ENC[datadog_user_database_password]'tags:- "dbinstanceidentifier:<DB_INSTANCE_NAME>"## Required for Postgres 9.6: Uncomment these lines to use the functions created in the setup# pg_stat_statements_view: datadog.pg_stat_statements()# pg_stat_activity_view: datadog.pg_stat_activity()## Optional: Connect to a different database if needed for `custom_queries`# dbname: '<DB_NAME>'
Agent バージョンが ≤ 7.49 の場合、インスタンス構成に host と port を指定して以下の設定を追加します。
ssl:allow
IAM で認証する場合は、region と instance_endpoint パラメーターを指定し、managed_authentication.enabled を true に設定します。
注: IAM 認証を使用する場合のみ managed_authentication を有効にしてください。IAM 認証は password フィールドよりも優先されます。
init_config:instances:- dbm:truehost:'<AWS_INSTANCE_ENDPOINT>'port:5432username:datadogaws:instance_endpoint:'<AWS_INSTANCE_ENDPOINT>'region:'<REGION>'managed_authentication:enabled:truetags:- "dbinstanceidentifier:<DB_INSTANCE_NAME>"## Required for Postgres 9.6: Uncomment these lines to use the functions created in the setup# pg_stat_statements_view: datadog.pg_stat_statements()# pg_stat_activity_view: datadog.pg_stat_activity()## Optional: Connect to a different database if needed for `custom_queries`# dbname: '<DB_NAME>'
It is common to configure a single Agent host to connect to multiple remote database instances (see Agent installation architectures for DBM). To connect to multiple hosts, create an entry for each host in the Postgres integration config.
In these cases, Datadog recommends limiting the number of instances per Agent to a maximum of 10 database instances to guarantee reliable performance.
Use the database_autodiscovery option to permit the Agent to discover all databases on your host to monitor. You can specify include or exclude fields to narrow the scope of databases discovered. See the sample postgres.d/conf.yaml for more details.
init_config:instances:- dbm:truehost:example-service-primary.example-host.comport:5432username:datadogpassword:'ENC[datadog_user_database_password]'database_autodiscovery:enabled:true# Optionally, set the include field to specify# a set of databases you are interested in discoveringinclude:- mydb.*- example.*tags:- 'env:prod'- 'team:team-discovery'- 'service:example-service'
In order to collect relation metrics (such as postgresql.seq_scans, postgresql.dead_rows, postgresql.index_rows_read, and postgresql.table_size), the Agent must be configured to connect to each database (by default, the Agent only connects to the postgres database).
Specify a single “DBM” instance to collect DBM telemetry from all databases. Use the database_autodiscovery option to avoid specifying each database name.
init_config:instances:# This instance is the "DBM" instance. It will connect to the# all logical databases, and send DBM telemetry from all databases- dbm:truehost:example-service-primary.example-host.comport:5432username:datadogpassword:'ENC[datadog_user_database_password]'database_autodiscovery:enabled:trueexclude:- ^users$- ^inventory$relations:- relation_regex:.*# This instance only collects data from the `users` database# and collects relation metrics from tables prefixed by "2022_"- host:example-service-primary.example-host.comport:5432username:datadogpassword:'ENC[datadog_user_database_password]'dbname:usersdbstrict:truerelations:- relation_regex:2022_.*relkind:- r- i# This instance only collects data from the `inventory` database# and collects relation metrics only from the specified tables- host:example-service-primary.example-host.comport:5432username:datadogpassword:'ENC[datadog_user_database_password]'dbname:inventorydbstrict:truerelations:- relation_name:products- relation_name:external_seller_products
Use the database_autodiscovery option to avoid specifying each logical database. See the sample postgres.d/conf.yaml for more details.
init_config:# This instance only collects data from the `users` database# and collects relation metrics only from the specified tablesinstances:- dbm:truehost:example-service-primary.example-host.comport:5432username:datadogpassword:'ENC[datadog_user_database_password]'dbname:usersdbstrict:truecollect_schemas:enabled:truerelations:- products- external_seller_products# This instance detects every logical database automatically# and collects relation metrics from every table- dbm:truehost:example-service–replica-1.example-host.comport:5432username:datadogpassword:'ENC[datadog_user_database_password]'database_autodiscovery:enabled:truecollect_schemas:enabled:truerelations:- relation_regex:.*
If the Agent must connect through a proxy such as the Cloud SQL Auth proxy, all telemetry is tagged with the hostname of the proxy rather than the database instance. Use the reported_hostname option to set a custom override of the hostname detected by the Agent.