このガイドでは、Amazon Aurora Postgres または MySQL データベースに対して Database Monitoring を構成していることを前提としています。

はじめに

サポートされるデータベース
Postgres、MySQL
サポート対象の Agent バージョン
7.53.0+

概要

Datadog の自動検出を使用すると、動的なインフラストラクチャーで監視を構成できます。この機能を使用すると、個々のデータベースホストエンドポイント (例えば、postgres.d/conf.yaml) を列挙することなく、Aurora クラスターを監視できます。これは、接続性やワークロードの変動に応じて Aurora レプリカの数を動的に調整する Aurora 自動スケーリングを使用するクラスターで特に役立ちます。Autodiscovery は、プライマリおよびレプリカエンドポイントインスタンスの両方を自動的に検出し、監視します。

Autodiscovery と Database Monitoring を使用すると、Postgres または MySQL チェックの構成テンプレートを定義し、各チェックを適用するクラスターを指定できます。

Aurora クラスターでオートディスカバリーを有効にする

  1. AWS 権限の付与
  2. Aurora タグの構成
  3. Datadog Agent の構成
  4. 構成テンプレートの作成

AWS 権限の付与

Datadog Agent は、AWS アカウント内で rds:DescribeDBClusters および rds:DescribeDBInstances を実行するための権限が必要です。Datadog は、Agent が実行されている EC2 インスタンスに IAM ロールポリシーをアタッチすることを推奨します。

これらの権限を与えるポリシーの例:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "rds:DescribeDBClusters",
        "rds:DescribeDBInstances"
      ],
      "Resource": [
        "arn:aws:rds:<region>:<account>:cluster:*",
        "arn:aws:rds:<region>:<account>:db:*"
      ]
    }
  ]
}

AmazonRDSReadOnlyAccess ポリシーをアタッチすることもできます。

Aurora タグの構成

リスナーは、Agent が実行されているアカウントおよびリージョン内の、datadoghq.com/scrape:true タグが適用されたすべての Aurora クラスターを検出します。特定のタグを持つクラスターを検出するように Agent を構成することもできます。

これらのタグを DB クラスターに適用する必要があります (ロール: Regional cluster)。RDS リソースのタグ付けに関する詳細は、AWS ドキュメントを参照してください。

tags を空の配列として構成すると、Autodiscovery はアカウントおよびリージョン内のすべてのクラスターを検出します。

Datadog Agent の構成

Autodiscovery は Agent サービスリスナーを使用します。Agent サービスリスナーは Aurora クラスター内のすべてのデータベースホストエンドポイントを発見し、発見されたエンドポイントを既存の Agent チェックスケジューリングパイプラインに転送します。リスナーは datadog.yaml ファイルで構成できます。

database_monitoring:
  autodiscovery:
    aurora:
      enabled: true

注: Agent は、Agent と同じリージョンで実行されている Aurora インスタンスのみを検出します。インスタンスのリージョンを特定するために、Agent は IMDS (Instance Metadata Service) を使用します。EC2 インスタンスが IMDSv2 を必要とする場合、以下に示すように、datadog.yaml 内の ec2_prefer_imdsv2: true を設定して Agent を IMDSv2 を使用するように構成する必要があります。

ec2_prefer_imdsv2: true
database_monitoring:
  autodiscovery:
    aurora:
      enabled: true

By default, the listener only discovers Aurora clusters in the account and region where the Agent is running, and only those with the datadoghq.com/scrape:true tag. You can also configure the listener to discover clusters with specific tags.

To specify custom tags for Aurora cluster discovery in the datadog.yaml file:

database_monitoring:
  autodiscovery:
    aurora:
      enabled: true
      tags:
        - "my-cluster-tag-key:value"

To monitor all clusters in the account and region:

database_monitoring:
  autodiscovery:
    aurora:
      enabled: true
      tags: []

The listener queries the AWS API for the list of hosts in a loop. The frequency with which the listener queries the AWS API, in seconds, is configurable in the datadog.yaml file:

database_monitoring:
  autodiscovery:
    aurora:
      enabled: true
      discovery_interval: 300

The listener provides an %%extra_dbm%% variable that can be used to enable or disable DBM for the instance. This value defaults to true if the tag datadoghq.com/dbm:true is present. To specify a custom tag for this value use dbm_tag:

database_monitoring:
  autodiscovery:
    aurora:
      enabled: true
      dbm_tag: "use_dbm:true"

The %%extra_dbm%% value is true if the tag is present, and false otherwise. It does not set its value to the value of the tag.

The listener provides an %%extra_global_view_db%% variable that can be used to set the global_view_db for the instance. This value defaults to the value of the tag datadoghq.com/global_view_db. To specify a custom tag for this value use global_view_db_tag:

database_monitoring:
  autodiscovery:
    aurora:
      enabled: true
      global_view_db_tag: "my_db_tag"

Create a configuration template

The Datadog Agent supports configuration templates for the Postgres and MySQL integrations. Define a configuration template for the Aurora clusters you wish to monitor.

まず、Aurora 管理の Postgres 用の ad_identifier を構成テンプレート (postgres.d/conf_aws_aurora.yaml) ファイルに追加します。

ad_identifiers:
  - _dbm_postgres_aurora

次に、テンプレートの残りを定義します。テンプレート変数を、host や port などの変更される可能性のあるパラメーターに使用します。

ad_identifiers:
  - _dbm_postgres_aurora
init_config:
instances:
  - host: "%%host%%"
    port: "%%port%%"
    username: datadog
    dbm: "%%extra_dbm%%"
    database_autodiscovery:
      enabled: true
    aws:
      instance_endpoint: "%%host%%"
      region: "%%extra_region%%"
    tags:
    - "dbclusteridentifier:%%extra_dbclusteridentifier%%"
    - "region:%%extra_region%%"

この例では、テンプレート変数 %%host%%、%%port%%、%%extra_dbclusteridentifier%%、%%extra_dbm%%、%%extra_region%% に Aurora クラスターからの情報が動的に入力されます。

認証

認証にパスワードを使用している場合、このテンプレートファイルで指定したパスワードは、検出されたすべてのデータベースで使用されることに注意してください。

パスワードを安全に保管

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.

以下の構成テンプレートの例は、Aurora クラスターで発見されたすべてのインスタンスに適用されます。

ad_identifiers:
  - _dbm_postgres_aurora
init_config:
instances:
  - host: "%%host%%"
    port: "%%port%%"
    username: datadog
    password: "ENC[datadog_user_database_password]"
    dbm: "%%extra_dbm%%"
    aws:
      instance_endpoint: "%%host%%"
      region: "%%extra_region%%"
    tags:
    - "dbclusteridentifier:%%extra_dbclusteridentifier%%"
    - "region:%%extra_region%%"
IAM Authentication

To use IAM authentication to connect to your Aurora cluster, use the following template:

ad_identifiers:
  - _dbm_postgres_aurora
init_config:
instances:
  - host: "%%host%%"
    port: "%%port%%"
    username: datadog
    dbm: true
    aws:
      instance_endpoint: "%%host%%"
      region: "%%extra_region%%"
      managed_authentication:
        enabled: "%%extra_managed_authentication_enabled%%"
    tags:
      - "dbclusteridentifier:%%extra_dbclusteridentifier%%"
      - "region:%%extra_region%%"

The template variable %%extra_managed_authentication_enabled%% resolves to true if the instance is using IAM authentication.

カスタムグローバルビューデータベース

データベースのオートディスカバリー用にカスタムグローバルビューデータベースを設定するには、Agent バージョン 7.75.0 以上を使用していることを確認し、次のテンプレートを使用してください。

ad_identifiers:
  - _dbm_postgres_aurora
init_config:
instances:
  - host: "%%host%%"
    port: "%%port%%"
    username: datadog
    dbm: true
    database_autodiscovery:
      enabled: true
      global_view_db: "%%extra_global_view_db%%"
    aws:
      instance_endpoint: "%%host%%"
      region: "%%extra_region%%"
    tags:
      - "dbclusteridentifier:%%extra_dbclusteridentifier%%"
      - "region:%%extra_region%%"

First, add an ad_identifier for Aurora-managed MySQL to your configuration template (mysql.d/conf_aws_aurora.yaml) file:

ad_identifiers:
  - _dbm_mysql_aurora

Then, define the remainder of the template. Use template variables for parameters that may change, such as host and port.

ad_identifiers:
  - _dbm_mysql_aurora
init_config:
instances:
  - host: "%%host%%"
    port: "%%port%%"
    username: datadog
    dbm: "%%extra_dbm%%"
    aws:
      instance_endpoint: "%%host%%"
      region: "%%extra_region%%"
    tags:
    - "dbclusteridentifier:%%extra_dbclusteridentifier%%"
    - "region:%%extra_region%%"

In this example, the template variables %%host%%, %%port%%, %%extra_dbclusteridentifier%%, %%extra_dbm%%, and %%extra_region%% are dynamically populated with information from the Aurora cluster.

Authentication

If you are using password for authentication note that the password provided in this template file will be used across every database discovered.

パスワードを安全に保管

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.

以下の構成テンプレートの例は、Aurora クラスターで発見されたすべてのインスタンスに適用されます。

ad_identifiers:
  - _dbm_mysql_aurora
init_config:
instances:
  - host: "%%host%%"
    port: "%%port%%"
    username: datadog
    password: "ENC[datadog_user_database_password]"
    dbm: "%%extra_dbm%%"
    aws:
      instance_endpoint: "%%host%%"
      region: "%%extra_region%%"
    tags:
    - "dbclusteridentifier:%%extra_dbclusteridentifier%%"
    - "region:%%extra_region%%"
IAM Authentication

To use IAM authentication to connect to your RDS instance, make sure that you are using Agent version 7.67.0 or above and use the following template:

ad_identifiers:
  - _dbm_mysql_aurora
init_config:
instances:
  - host: "%%host%%"
    port: "%%port%%"
    username: datadog
    dbm: true
    aws:
      instance_endpoint: "%%host%%"
      region: "%%extra_region%%"
      managed_authentication:
        enabled: "%%extra_managed_authentication_enabled%%"
    tags:
      - "dbclusteridentifier:%%extra_dbclusteridentifier%%"
      - "region:%%extra_region%%"

The template variable %%extra_managed_authentication_enabled%% resolves to true if the instance is using IAM authentication.

インテグレーションによる Autodiscovery の構成の詳細については、Autodiscovery のドキュメントを参照してください。

サポートされているテンプレート変数

テンプレート変数ソース
%%host%%Aurora インスタンスエンドポイント
%%port%%Aurora インスタンスのポート
%%extra_region%%インスタンスが配置されている AWS リージョン
%%extra_dbclusteridentifier%%発見された Aurora クラスターのクラスター識別子
%%extra_dbm%%クラスターで DBM が有効かどうか。dbm_tag の存在によって決定され、デフォルトは datadoghq.com/dbm:true です。
%%extra_managed_authentication_enabled%%クラスターで IAM 認証が有効かどうか。
これは、コネクションにマネージド認証を使用すべきかどうかを判断するために使用されます。
%%extra_global_view_db%%global_view_db_tag の値であり、デフォルトは datadoghq.com/global_view_db です。